0

"If" problem

#include <iostream> using namespace std; int main() { int grade; cout << "Enter your grade\n"; cin >> grade; if (grade<=100 && grade >=0) { if (grade<=100 && grade>=94) { cout << "Your grade is A";}; if (grade<=93 && grade>=90) { cout << "Your grade is A-";}; if (grade<=89 && grade>=87) { cout << "Your grade is B+";}; if (grade<=86 && grade>=83) { cout << "Your grade is B";}; if (grade<=82 && grade>=80) { cout << "Your grade is B-";}; if (grade<=79 && grade>=77) { cout << "Your grade is C+";}; if (grade<=76 && grade>=73) { cout << "Your grade is C";}; if (grade<=72 && grade>=70) { cout << "Your grade is C-";}; if (grade<=69 && grade>=67) { cout << "Your grade is D+";}; if (grade<=66 && grade>=60) { cout << "Your grade is D";}; if (grade<=59 && grade>=0) { cout << "Your grade is F";}; } else {cout << "ENTER NUMBERS FROM 0-100";} return 0; } when I input letters (f.e: ab) it outputs Your grade is F I wanted it to output ENTER NUMBERS FROM 0-100 What's the problem?

25th Nov 2017, 9:23 PM
gogamid
6 Respostas
0
and why when I open .exe file I input but after closes immediately.
25th Nov 2017, 9:35 PM
gogamid
0
Thank you. As I understood , I should’ve been define string also?
25th Nov 2017, 10:41 PM
gogamid
0
My question is that my program should output my grade if I will input the numbers 0-100, BUT if i will write any character or numbers other than 0-100, it should output ENTER NUMBERS BETWEEN 0-100
25th Nov 2017, 11:54 PM
gogamid