+ 1

I need help guys

Write a program called DecisionMaking. The program should prompt the user to enter two integers. The program should store these values into variables a and b and compare the two integers entered then say which number is greater than the other. E.g. If a user enters 20 and 40, the program should say that 40 is greater than 20. If the values entered are equal the program should display that the first number is equal to the second number or else display that invalid data has been entered. Use if els

3rd Oct 2018, 6:52 AM
Abraham Shilikomwenyo
Abraham Shilikomwenyo - avatar
4 Answers
+ 8
estifanos tekiea Read Abraham Shilikomwenyo thread again, he had written if both numbers are equal then program should display that first number is equal to second number or else display invalid data has entered. So we need another "else if" t to display if values are equal. If no condition satisfies then it should go to the else statement 😊
3rd Oct 2018, 1:44 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 7
estifanos tekiea there's an error in your code, if both numbers are equal program will output "Invalid data had been entered" which it shouldn't be
3rd Oct 2018, 8:15 AM
blACk sh4d0w
blACk sh4d0w - avatar
0
int a,b; cin>>a; cin>>b; if(a>b){ cout <<a<<"is greater than"<<b; }else if(b>a){ cout<<b<<"is greater than"<<a; }else{ cout <<"invalided data had been entered ";
3rd Oct 2018, 7:18 AM
estifanos
estifanos - avatar
0
nAutAxH AhmAd there is three probability in this case 1, a is greater than b 2, b is greater than a 3, bother are equal so if the first and the second condition are false then the 3rd statement will be execute which means both are equal so we don't need another "else if" statement the "else" statement is enough to describe that
3rd Oct 2018, 10:31 AM
estifanos
estifanos - avatar