60 736
Assignments Done
97,9%
Successfully Done
In April 2018

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.
Expert's answer
# 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

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions