Answer to Question #19935 in C++ for Aarthi Vishwanathan

Question #19935
An array stores details of 25 students (rollno, name, marks in 3 subjects). Write a program in C++ 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.
1
Expert's answer
2012-12-05T09:46:27-0500
# include <iostream>
# include <string>
using namespace std;
class stud{
char *rollno;
char *name;
double m[3];
public:
stud(){}
~stud(){delete [] name; delete [] rollno;}
void get(){
& name = new char [20];
& rollno = new char [15];
&
& cout<<"enter name: ";
& cin.getline(name,20,'\n');
& cout<<"enter rollno: ";
& cin.getline(rollno,15,'\n');
& for(int i=0;i<3;i++){
& cout<<"enter mark"<<i<<": ";
& cin>>m[i];
& }
& cin.ignore();
}
void out(){
& int t(0);
& if (m[0]<40) t++;
& if (m[1]<40) t++;
& if (m[2]<40) t++;
& if (t>=2) put();
}
void put(){
& cout<<name<<" "<<rollno<<endl;
}
};

int main(){
const int num=2;
stud a[25];
cout<<"At first enter 25 students!\n";
for (int i=0;i<num;i++){
& a[i].get();
}
cout<<"failed students:\n";
for (int i=0;i<num;i++){
& a[i].out();
}

system("PAUSE");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
15.05.18, 19:32

Dear visitor, please use panel for new questions

Ankit Thakur
15.05.18, 13:34

An array stores details of 5 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 subjects. Assume 40% as pass marks. Use array of structures with functions.

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS