"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Tuesday, April 6, 2010

An array stores details of 25 students (rollno, name, marks in 3 subjects). Write a program to create such an array and print out a list of students who have failed in more than one subject. Assume 40% as pass marks.

#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();

}

1 comment:

  1. i need the same program using in c could u help me.
    venkatprince.s@gmail.com

    ReplyDelete

Loading...
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My Photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.