Write a program to create an array which stores the details of 25 students (name, rollno, marks in
four subjects) and print the list of students who have failed in more than one subject (passing
marks >= 30)
Answers
Answer:
The following is a program to create an array which stores the details of 25 students and print the names of students who have failed.
#include<iostream.h>
#include<conio.h>
struct stud
{
int roll;
char name[50];
float m1,m2,m3,m4;
};
typedf stud S;
void main()
{
S student[25];
For(int i=0;i<25;i++)
{
cout<<”\n enter roll number of the student: \n ”;
cin>>student[i].roll;
cout<<”\n enter name of the student: \n ”;
cin>>student[ch].name;
cout<<”\n enter marks scored in 4 subjects: \n ”;
cin>>student[i].m1>>student[i].m2>>student[i].m3>>student[i].m4;
}
cout<<”\n enter students who failed in more than 1 subject \n”;
for(i=0;i<25;i++)
{
If((student[i].m1<30 && student[i].m2<30))||
(student[i].m2<30 && student[i].m3<30)||
((student[i].m1<30 && student[i].m3<30))
cout<<student[i].roll<<”\t”<<student[i].name<<”\n”;
}
getch();
}