fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct Node {
  5. int data;
  6. struct Node* next;
  7. };
  8. struct Node* head;
  9. void insert(int data, int n)
  10. {
  11. struct Node* temp1 = (struct Node*)malloc(sizeof(struct Node*));
  12. temp1->data = data;
  13. temp1->next = NULL;
  14. if(n==1){
  15. temp1->next = head;
  16. head = temp1;
  17. return;
  18. }
  19. struct Node* temp2 = head;
  20. for(int i=0;i<n-2;i++){
  21. temp2 = temp2->next;
  22. }
  23. temp1->next = temp2->next;
  24. temp2->next = temp1;
  25. }
  26. void print(struct Node* temp){
  27. temp = head;
  28. while(temp != NULL){
  29. printf("%d ",temp->data);
  30. temp = temp->next;
  31. }
  32. printf("\n");
  33. }
  34. int main(void) {
  35. head = NULL;
  36. insert(2,1);
  37. insert(3,2);
  38. insert(4,1);
  39. insert(5,2);
  40. print();
  41. // your code goes here
  42. return 0;
  43. }
  44.  
  45.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'main':
prog.c:40:2: error: too few arguments to function 'print'
  print();
  ^
prog.c:26:6: note: declared here
 void print(struct Node* temp){
      ^
stdout
Standard output is empty