ACP3_2

//BCA Support - www.bcasupport.xyz #include <stdio.h> #include <alloc.h> void main() { struct node{ int no; struct node *next; }*node,*start,*temp; char ch='y'; clrscr(); start=(struct node *)malloc(sizeof(struct node)); node=start; while(ch=='y') { clrscr(); printf("\nInput no. : "); flushall(); scanf("%d",&node->no); printf("\nEnter y to enter another no. : "); flushall(); scanf("%c",&ch); if(ch=='y') { node->next=(struct node *)malloc(sizeof(struct node)); node=node->next; } else { node->next=NULL; } } node=start; clrscr(); printf("\nValues :"); while(node->next!=NULL) { printf("\n%d",node->no); node=node->next; } printf("\n%d\n",node->no); printf("\nEnter value to insert as ending node : "); temp=(struct node *)malloc(sizeof(struct node)); flushall(); scanf("%d",&temp->no); node->next=temp; temp->next=NULL; node=start; printf("\nValues after insertion :"); while(node->next!=NULL) { printf("\n%d",node->no); node=node->next; } printf("\n%d\n",node->no); getch(); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.