1.

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.

Answer»

struct student

{

char name [10];

float marks [3];

int maxmarks;

float total=0.0, percentage=0.0;

}s;

void main ()

{

int i;

cout << “enter name”;

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

{

cin>>s.marks [i];

s. total + = s.marks [i];

}

cout<<"Enter total marks";

cin>>s.maxmarks;

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

cout << “ student details “<<endl;

cout <<”Name” << s. name;

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

<<

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

endl;

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

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

}



Discussion

No Comment Found

Related InterviewSolutions