The Admission to a professional course is done using the following conditions.
a) Marks in Maths> =60
b) Marks in Physics >=50
c) Marks in chemistry >=40
d) Total in all the three subjects >=200 (or) Total in Maths and Physics >=150
Given the marks of three subjects, write a C++ program to process the applications to list the eligible candidates. [Note: Use call by value]
//C++ program to process the applications to
// list the eligible candidates
#include <iostream>
using namespace std;
bool candidates(int, int, int);
int main() {
int Maths, Physics, Chemistry;
cout << "The following conditions must be met:" << endl;
cout << "Marks in Maths >=60" << endl;
cout << "Marks in Physics >=50" << endl;
cout << "Marks in Chemistry >=40" << endl<<endl;
cout << "Total in all the three subjects >=200" << endl;
cout << "(or) Total in Maths and Physics >=150" << endl;
cout << "********************************************" << endl;
cout << "Input the marks obtained in Mathematics : ";
cin >> Maths;
cout << "Input the marks obtained in Physics : ";
cin >> Physics;
cout << "Input the marks obtained in Chemistry : " ;
cin >> Chemistry;
cout << endl;
if(candidates(Maths, Physics, Chemistry))
cout << "The candidate is eligible for admission." << endl;
else
cout << "The candidate is not eligible for admission."<< endl;
return 0;
}
bool candidates(int Maths, int Physics , int Chemistry) {
int Total3, Total2;
Total3 = Maths + Physics + Chemistry;
Total2 = Maths + Physics;
cout << "Total marks of Maths, Physics and Chemistry : "<< Total3 << endl;
cout << "Total marks of Maths and Physics : "<< Total2 << endl;
if (Maths >=60)
if(Physics >=50)
if(Chemistry >=40)
if(Total3 >=200 ||Total2 >=150)
return 1;
else
return 0;
else
return 0;
else
return 0;
else
return 0;
}
Comments
Leave a comment