Program To Find Grade of Student in C++ Using IF…ELSE Statement

Program Logic:

This Program is made to find grade of student in C++.  User is required to input marks obtained and then program gives him a grade according to his marks. The grading scale is shown below:

Marks                                         Grade

90——-100                                     A+

80——-89                                       A

70——-79                                        B

60——-69                                        C

50——-59                                        D

00——-49                                        F

 Recommended reading: Find Sum of Digits of A Number in C++

Code To Find Grade of Student in C++:

Code Explanation:

First we declared a variable named marks to take input from user.

After receiving input,  this variable is tested using IF…ELSE statement.

Because we want to check number between two ranges, So we used And operator ( && ) to combine the conditions.

The true block of a particular executes only if both conditions are true. For example if user inputs number 98 then first IF block becomes true because this number is greater than 90 and less then 100. So Program will print “Your Grade is A+.” without quotations.

If marks are greater than 100 then program will print error message saying “Invalid input.”.

 Recommended reading: Tower Of Hanoi Using Stacks in C++

Program Output:

Program to Find Grade of Student in C++

I hope now you can write C++ program to calculate grade of student using IF…ELSE statement.

If you liked this article, then I would really appreciate if you follow us on Twitter and Facebook.

If you have any question then you can ask me in comments. I would like to answer them.

You can also Click Here To Download Exercise Files.