Develop a C++ program to get the CGPA and print the following status according to the given CGPA by using else if ladder statement. [Note: Use call by value]
1. CGPA < 50 "FAIL"
2. 50 >= CGPA <=60 "FIRST"
3. 60 > CGPA <=70 "SECOND"
4. 70 > CGPA <=80 "THIRD"
5. CGPA >80 "DISTINCTION"
#include <iostream>
#include <string>
using namespace std;
string getstatus(int arg) {
string result;
if (arg < 50) {
result = "FAIL";
}
else if (arg >= 50 && arg <= 60) {
result = "FIRST";
}
else if (arg >60 && arg <=70) {
result = "SECOND";
}
else if (arg >70 && arg <= 80) {
result = "THIRD";
}
else if (arg > 80) {
result = "DISTINCTION";
}
return result;
}
int main()
{
int cpgaCount;
string cpgaStatus;
std::cout << "Enter an integer number of CGPA points: ";
std::cin >> cpgaCount;
cpgaStatus = "Current status: " + getstatus(cpgaCount);
std::cout << cpgaStatus << std::endl;
}
Comments
Leave a comment