Advertisement
SOIKAT

Untitled

Mar 1st, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. struct node
  4. {
  5.     int data;
  6.     struct node* link;
  7. };
  8. struct node* head=NULL;
  9. void insert()
  10. {
  11.     struct node* temp=(struct node*)malloc(sizeof(struct node));
  12.     int data;
  13.     printf("Insert Elemmment:");
  14.     scanf("%d",&data);
  15.     temp->data=data;
  16.     temp->link=NULL;
  17.     temp->link=head;
  18.     head=temp;
  19. }
  20. display()
  21. {
  22.     struct node* p=head;
  23.     printf("The Element are:");
  24.     while(p!=NULL)
  25.     {
  26.         printf("%d ",p->data);
  27.         p=p->link;
  28.     }
  29.     printf("\n");
  30. }
  31. int main()
  32. {
  33.     insert();
  34.     insert();
  35.     insert();
  36.     insert();
  37.     insert();
  38.     display();
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement