#include
#include
#include
struct linkedlist
{
int data;
struct linkedlist *next;
};
typedef struct linkedlist node;
void main()
{
node *head,*ptr,*new1;
char ch;
int large;
clrscr();
head=(node *)malloc(sizeof(node));
ptr=head;
do
{
printf("\nEnter the data \n");
scanf("%d",&ptr->data);
printf("\nDo you want to continue(y/n):");
ch=getch();
if(ch=='y')
{
clrscr();
ptr->next=(node *)malloc(sizeof(node));
ptr->next=new1;
ptr=ptr->next;
}
else
ptr->next=NULL;
}
while(ch!='n');
ptr=head;
large=ptr->data;
// printf("\nLinklist elements are:\n");
while(ptr!=NULL)
{
ptr=ptr->next;
if(ptr->data>large)
large=ptr->data;
}
printf("\nLargest Number in linked list= %d\t",large);
getch();
}
6:40 PM |
Category: |
0
comments
Comments (0)