An array stores details of 25 students (rollno, name, marks in three subject). Write a program to create such an array and print out a list of students who have failed in more than one subject. [hint : use struct]
Answers
An array stores details of 25 students (rollno, name, marks in three subject):
#include<iostream.h>
#include<conio.h>
struct stud
{
int roll;
char nm[50];
float m1, m2, m3;
};
typedef stud S;
void main()
{
S student[25];
for(int i =0 ; i < 25 ; i++)
{
cout << "\n Enter Roll no : ";
cin >> student[i].roll;
cout << "\n Enter Name : "
cin.getline(student[i].nm, 50);
cout << "\n Enter marks of three subjects :";
cin >> student[i].m1 >> student[i].m2 >> student[i].m3 ;
}
cout<< "\n STUDENTS FAILED IN MORE THAN 1 SUBJECT \n ";
for(i =0 ; i < 25 ; i++)
{
if(( student[i].m1< 40 && student[i].m2 < 40) || (student[i].m2 < 40 && student[i].m3 < 40) || ( student[i].m1 < 40 && student[i].m3 < 40))
cout << student[i].roll << "\t" << student[i].nm << "\n";
}
getch();
}
Learn more about array:
https://brainly.in/question/2337020