C Assignment to calculate total percentage in c by using structures

C Assignment to calculate total percentage in c by using structures


#include
#include
struct student
{
char name[20];
int age;
int RollNo;
int marks[6];
int total;
float per;
};
void setmarks(struct student *);
void calculate(struct student *);
void display(struct student *);
void main()
{

struct student s1={"xyz",23,131},*ptr;
clrscr();
ptr=&s1;
printf("\n Student Name=%s",ptr->name);
printf("\n student Age=%d",ptr->age);
printf("\n student roll number=%d",ptr->RollNo);
setmarks(&s1);
calculate(&s1);
display(&s1);
getch();
}
void setmarks(struct student * m)
{
int i;
printf("\n Enter marks getting in 6 subjects.........\n");
m->total=0;
for(i=0;i<6;i++)
{
scanf("%d",&m->marks[i]);
m->total=m->total+m->marks[i];
}
}
void calculate(struct student * p)
{
p->per=p->total/600.0*100;
}
void display(struct student * d)
{
printf("\n student Name=%s",d->name);
printf("\n student age=%d",d->age);
printf("\n student roll no=%d",d->RollNo);
printf("\n student total markse=%d",d->total);
printf("\n student percentage=%f",d->per);
}




No comments:

Post a Comment