Jan

23

#include<stdio.h>

#include<malloc.h>

void main(){

struct node

{

int num;

struct node *next;

}*start=NULL;

typedef struct node NODE;

NODE *p, *first=NULL,*temp;

char choice;

clrscr();

do{

p=(NODE*) malloc(sizeof(NODE));

printf(“Enter the data item\n”);

scanf(“%d”,&p->num);

if(first==NULL){

p->next=NULL;

temp=p;

first=p;

}

else{

temp->next=p;

p->next=NULL;

temp=p;

}

printf(“Do you want to continue (type y or n) ?\n”);

fflush(stdin);

scanf(“%c”,&choice);

}while(choice==’y’ || choice==’Y’);

printf(“Status of Link List is ——————–\n”);

temp=first;

while(temp!=NULL){

printf(“%d\n”,temp->num);

temp=temp->next;

}

//printf(“Number of Nodes in the list = %d\n”,count);

getch();

}


Leave a Reply