#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct student
{
int tot;
int rollno;
char name[10];
int marks;
struct student *next,*pre;
};
void main()
{
int sub1,sub2,sub3,sub4,sub5;
int tot;
struct student *start,*ptr;
char ch='y';
start=NULL;
clrscr();
while(ch=='y')
{
if(start==NULL)
{
start=ptr=malloc (sizeof (struct student));
start->pre=ptr;
}
else
{
ptr->next=malloc (sizeof (struct student));
ptr->next->pre=ptr;
ptr=ptr->next;
}
ptr->next=NULL;
printf("\n enter any rollno :");
scanf("%d",& ptr->rollno);
printf("\n enter name :");
scanf("%s",& ptr->name);
printf("\n enter marks of 1st subject :");
scanf("%d",& sub1);
printf("\n enter marks of 2nd subject :");
scanf("%d",& sub2);
printf("\n enter marks of 3rd subject :");
scanf("%d",& sub3);
printf("\n enter marks of 4th subject :");
scanf("%d",& sub4);
printf("\n enter marks of 5th subject :");
scanf("%d",& sub5);
ptr->tot=sub1+sub2+sub3+sub4+sub5;
printf("\n Total marks of a student is : %d",ptr->tot);
printf("\n \n enter your choice (y/n):");
fflush(stdin);
scanf("%c",& ch);
}
for(ptr=start;ptr!=NULL;ptr=ptr->next)
{
printf("\n\n Rollno. of a student : %d",ptr->rollno);
printf("\n Name of a student : %s",ptr->name);
printf("\n Total marks of a student : %d",ptr->tot);
}
getch();
}
0 comments:
Post a Comment