Question #41484

write a prolog code that accepts input of CGPA from user and determine the level of that CGPA

Expert's answer

`#include <iostream>`

char determineGrade (double CGPA) {

if ( CGPA <= 100 && CGPA >= 90 ) {

return 'A';

}

if ( CGPA >=80 && CGPA <=89 ) {

return 'B';

}

if ( CGPA >= 70 && CGPA <= 88 ) {

return 'C';

}

if ( CGPA >=65 && CGPA <= 69 ) {

return 'D';

}

if ( CGPA <= 64 ) {

return 'F';

}

}

int main() {

double CGPA = 0;

std::cout << "Please input the CGPA in percentage." << std::endl;

std::cin >> CGPA;

while ( CGPA < 0 || CGPA > 100 ) {

std::cout << "Acceptable values are from 0 till 100" << std::endl;

std::cin >> CGPA;

}

std::cout << "Your grade is " << determineGrade(CGPA) << std::endl;

return 0;

}

## Comments

## Leave a comment