Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- struct node
- {
- int data;
- struct node* link;
- };
- struct node* head=NULL;
- void insert()
- {
- struct node* temp=(struct node*)malloc(sizeof(struct node));
- int data;
- printf("Insert Elemmment:");
- scanf("%d",&data);
- temp->data=data;
- temp->link=NULL;
- temp->link=head;
- head=temp;
- }
- display()
- {
- struct node* p=head;
- printf("The Element are:");
- while(p!=NULL)
- {
- printf("%d ",p->data);
- p=p->link;
- }
- printf("\n");
- }
- int main()
- {
- insert();
- insert();
- insert();
- insert();
- insert();
- display();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement