fork download
  1. #include<iostream>
  2. #include<stdlib.h>
  3. using namespace std;
  4.  
  5. struct list{
  6. struct list * next;
  7. int data;
  8. }*head;
  9.  
  10. int Creat_list(int num)
  11. {
  12. struct list *temp;
  13. struct list *q;
  14. q=head;
  15. temp = new list;
  16. temp->data=num;
  17. if(head==NULL){
  18. head=temp;
  19. head->next=NULL;
  20. }
  21. else
  22. {
  23. while(q->next!=NULL)
  24.  
  25. q=q->next;
  26. q->next=temp;
  27. q=temp;
  28. q->next=NULL;
  29. }
  30.  
  31. }
  32. count()
  33. {
  34. int count=0;
  35. struct list *c1;
  36. c1=head;
  37. while(c1!=NULL)
  38. {
  39. cout<<"->"<<c1->data;
  40. count++;
  41. c1=c1->next;
  42. }
  43. }
  44. cout<<"no of nodes %d"<<count;
  45. }
  46.  
  47. int main() {
  48. // your code goes here
  49. head=NULL;
  50. int i, num;
  51. for (i=0;i<4;i++)
  52. {
  53. printf("Enter number");
  54. scanf("%d",&num);
  55. Creat_list(num);
  56. }
  57. count();
  58. return 0;
  59. }
  60.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:32:7: error: ISO C++ forbids declaration of ‘count’ with no type [-fpermissive]
 count()
       ^
prog.cpp:44:2: error: ‘cout’ does not name a type
  cout<<"no of nodes %d"<<count;
  ^~~~
prog.cpp:45:1: error: expected declaration before ‘}’ token
 }
 ^
stdout
Standard output is empty