Put condition on int about its range

I made a program which gives grade after checking marks. The condition i want for the first if statement should check if the value of the variable 'marks' is between 0 and 100 (inclusive) then execute the code otherwise output the text specified.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
using namespace std;

int main()
{
	cout << "Enter marks: ";
	int marks;
	cin >> marks;	
	if ( /* condition here */)
	{
		if ( marks==100)
		{
			cout << "You got a perfect score.";
		}
		else if ( marks<100 && marks>=90)
		{
			cout << "You scored an A grade.";
		}
		else if ( marks<90 && marks>=80)
		{
			cout << "You scored an B grade.";
		}
		else if ( marks<80 && marks>=70)
		{
			cout << "You scored an C grade.";
		}
		else if ( marks<70 && marks>=60)
		{
			cout << "You scored an D grade.";
		}
		else if ( marks<60)
		{
			cout << "You scored an F grade.";
		}
	}
	else 
	{
		cout << "The marks entered are out of range.";
	}
	
	return 0;
}
(marks >= 0 && marks <=100)
oh... that was much simpler than expected. :D thanks
Topic archived. No new replies allowed.