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>
void print_status(int cpga)
{
if ( cpga < 50 )
{
std::cout << "FAIL" << std::endl;
}
else if ( cpga >= 50 && cpga <= 60 )
{
std::cout << "FIRST" << std::endl;
}
else if ( cpga > 60 && cpga <= 70 )
{
std::cout << "SECOND" << std::endl;
}
else if ( cpga > 70 && cpga <= 80 )
{
std::cout << "THIRD" << std::endl;
}
else if ( cpga > 80 )
{
std::cout << "DISTINCTION" << std::endl;
}
}
int main()
{
int cpga;
std::cout << "Enter CGPA: ";
std::cin >> cpga;
print_status( cpga );
return 0;
}
Comments
Leave a comment