//BCA Support - www.bcasupport.xyz
#include <stdio.h>
#include <alloc.h>
void main()
{
struct node{
int no;
struct node *next;
}*node,*start;
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);
if(start->next==NULL)
{
printf("\nThere's only one node in the link list!");
getch();
exit();
}
node=start;
start=node->next;
node=start;
printf("\nValues after deleting starting node :");
while((node->next)!=NULL)
{
printf("\n%d",node->no);
node=node->next;
}
printf("\n%d",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.