Develop a C++ program that finds the minimum of 4 even numbers entered by the user.?
The program should display the following grades if the minimum value is found within the given interval;
60-100 A
40-59 B
30-39 C
Below 30 Fail

6 Days
Discussion Span
Last Post by tinstaafl

Is this a program you are hiring to develop? If so, tell how much it pays and if there is more work in the future.

My bet is it's your homework. If homework, show your work and where you run into an issue.


Then you have to show your work and tell us where you are having a block/issue. The forum is more about helping you in a specific issue rather than providing homework solutions.


Program That Finds The Minimum of 4 Even Numbers Entered by the User. The program should display the following grades if the minimum value is found within the given interval;

60-100 A,
40-59 B,
30-39 C,
Below 30 Fail

My code seems to display ONLY FAIL even when i input odd numbers(any number i input odd or even, it displays FAIL) which is not suppose to be so. Below is my code

int main() 

double a; 
double b; 
double c; 
double d; 
double minval; 

cout << "Input a value for a: " << endl; 
cin >> a; 
cout << "Input a value for b: " << endl; 
cin >> b; 
cout << "Input a value for c: " << endl; 
cin >> c; 
cout << "Input a value for d: " << endl; 
cin >> d; 

cout << "\nTHIS IS YOUR GRADE: " << endl; 

if (minval > a) 

minval = a; 

if (minval > b) 

minval = b; 

if (minval > c) 

minval = c; 

if (minval > d) 

minval = d; 

if ((minval >= 60) && (minval <= 100)) 

cout << "\nGrade \t A" << endl; 

else if ((minval >= 40) && (minval <= 59)) 

cout << "\nGrade \t B" << endl; 

else if ((minval >= 30) && (minval <= 39)) 

cout << "\nGrade \t C" << endl; 

else if ((minval < 30) && (minval >= 0)) 

cout << "\nFail" << endl; 


cout << "Enter Valid Numbers" << endl; 

return 0;

Edited by Reverend Jim: Corrected code formatting



Try putting your code online in a C++ fiddle as it stands your badly formatted and incomplete code dump isn't something I can toss into a C++ fiddle. Try a C++ from this link: https://fiddles.io/#


Whitespace, properly used, increases code readability. Whitespace, used improperly, decreases readability, and can often introduce bugs.


The first that jumps out at me, is you're not setting a value to minval, which means that it'll get assigned the default value of 0. Therefore none of the numbers chosen will be less than that. Giving it the maximum allowed value, will ensure that whatever is chosen will be less than it. Luckily the standard library has a constant for that:

double minval = DBL_MAX;

Edited by tinstaafl

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.