. An array stores details of 25 students (rollno, name, marks in three subjects). Write a program to create such an array and print out a list of students who have failed in more than one subject.
Coding With Farhan
We Are Considering The Fail Marks 50
Source Code
#include <iostream>
using namespace std;
struct student
{
int roll;
char name[50];
float marks1, marks2, marks3;
};
int main()
{
student S[2];
for (int i = 0; i < 2; i++)
{
cout << "Enter Roll No :- ";
cin >> S[i].roll;
cout << "Enter Name :- ";
cin >> S[i].name;
cout << "Enter Marks Of Three Subjects :- ";
cin >> S[i].marks1 >> S[i].marks2 >> S[i].marks3;
}
cout << "Students Failed In More Than 1 Subject" << endl;
for (int i = 0; i < 2; i++)
{
if ((S[i].marks1 < 50 && S[i].marks2 < 50) || (S[i].marks2 < 50 && S[i].marks3 < 50) || (S[i].marks1 < 50 && S[i].marks3 < 50))
{
cout << S[i].roll << "\t" << S[i].name << endl;
}
}
}
Link To Download This Source Code
If you have any problems regarding this program or you have to understand something regarding this program please let me know, Thank You!
Comments
Post a Comment