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 *add;
- };
- struct node *start=NULL,*temp,*New;
- void create();
- void display();
- void main(){
- int n;
- scanf("%d" , &n);
- create();
- display();
- }
- void create()
- {
- int n;
- char ch;
- if(start == NULL)
- {
- scanf("%d",&n);
- start = (struct node *)malloc(sizeof(struct node));
- start->data = n;
- start->add = NULL;
- temp = start;
- scanf(" %c",&ch);
- while(ch=='Y' || ch=='y')
- {
- scanf("%d",&n);
- New = (struct node *)malloc(sizeof(struct node));
- New->data = n;
- New->add = NULL;
- temp->add = New;
- temp = New;
- scanf(" %c",&ch);
- }
- }
- else
- {
- printf("\nList already created\n");
- }
- }
- void display()
- {
- if(start == NULL)
- {
- printf("\nLink list not created, create a list first\n");
- }
- else
- {
- printf("\n");
- temp = start;
- while(temp!=NULL)
- {
- printf("%d ",temp->data);
- temp=temp->add;
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement