C++ Program to Print Grade Based on Percentage

Write C++ Program to Print Grade Based on Percentage

// CPP Program to Print Grade Based on Percentage

#include <iostream>

using namespace std;

int main()
{
	float Percentage;

	cout << "Enter the percentage :--> ";
	cin >> Percentage;

	if(Percentage < 33.0)
	{
		cout << "Oops! You are failed";
	}
	else if(Percentage >= 33.0 & Percentage <= 40.0)
	{
		cout << "You have passed the exam with D Grade";
	}
	else if(Percentage >= 41.0 & Percentage <= 50.0)
	{
		cout << "You have passed the exam with C2 Grade";
	}
	else if(Percentage >= 51.0 & Percentage <= 60.0)
	{
		cout << "You have passed the exam with C1 Grade";
	}
	else if(Percentage >= 61.0 & Percentage <= 70.0)
	{
		cout << "You have passed the exam with B2 Grade";
	}
	else if(Percentage >= 71.0 & Percentage <= 80.0)
	{
		cout << "You have passed the exam with B1 Grade";
	}
	else if(Percentage >= 81.0 & Percentage <= 90.0)
	{
		cout << "You have passed the exam with A2 Grade";
	}
	else if(Percentage >= 91.0 & Percentage <= 100.0)
	{
		cout << "You have passed the exam with A1 Grade";
	}
	else
	{
		cout << "Please Enter the percentage in the range of 0 to 100";
	}

	return 0;

}

Output:

Run 1:
Enter the percentage :--> 69.9
Congratulation! You have passed the exam having B2 Grade

Run 2:
Enter the percentage :--> 23.26
Oops! You are failed

Run 3:
Enter the percentage :--> 89.98
Congratulation! You have passed the exam having A2 Grade

Run 4:
Enter the percentage :--> 121
Please Enter the percentage in the range of 0 to 100

≪ Previous | Next ≫