+1 vote
in Class 12 by kratos

Write a program using structure to accept the name and marks in 3 subjects for a student. Calculate the total marks, percentage. Display the name, marks, total and percentage using the structure variable.

1 Answer

+2 votes
by kratos
 
Best answer

struct student

{

char name [10];

float marks [3];

int maxmarks;

float total=0.0, percentage=0.0;

}*;

void main ()

{

int i;

cout << “enter name”;

for (i=0; i<3;i++)

{

cin>>*.marks [i];

. total + = .marks [i];

}

cout<<"Enter total marks";

cin>>*.maxmarks;

. percentage = (.total*s.maxmarks)/100;

cout << “ student details “<<endl;

cout <<”Name” << *. name;

cout <<” marks” << *.marks [1] << “/t”

<<

. marks [2] << “\t” << . marks [3] <<

endl;

cout << “ percentage:” << *. percentage;

cout << “ Total:” << *. total;

}

...