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);
}




Related Links :

No comments:

Post a Comment


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!