Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct my
- {
- int data;
- struct my *then;
- }my;
- my *head = NULL;
- int main()
- {
- int i,m,n;
- my *coming,*again;
- printf("Data entered in the list : ");
- scanf("%d",&m);
- for(i=1;i<=m;i++)
- {
- printf("Inpute data for node %d : ",i);
- scanf("%d",&n);
- coming = malloc(sizeof(my));
- coming->data = n;
- coming->then = NULL;
- if(head==NULL)
- {
- head = coming;
- }
- else
- {
- again = head;
- while(again -> then != NULL)
- {
- again = again->then;
- }
- again->then = coming;
- }
- }
- again=head;
- printf("Data entered in the list :\n");
- while(again!=NULL)
- {
- printf(" Data=%d\n",again->data);
- again=again->then;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement