//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);
node=start;
printf("\nEnter value to insert as starting node : ");
temp=(struct node *)malloc(sizeof(struct node));
flushall();
scanf("%d",&temp->no);
temp->next=start;
start=temp;
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.