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