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(); }
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
Thank you! Your comments have been successfully added. However, they need to be checked by the moderator before being published.
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Dear visitor, please use panel for new questions
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