Basic Grading System for Students || Switch Case || C++ || Turbo C++
In this we are going to see how to make a basic Grading System for a Student Program in C++.

The code given below can be used for TURBO C++ Compiler:-

#include <iostream.h>
#include <conio.h>

void main()
{
        clrscr();
	int a, b, c;
	cout << "Enter marks out of 150 \n";
	cin >> a;
	b = (a * 100) / 150;
	cout << "For results choose the below options \n";
	cout << "1. Result in percentage \n 2. Result in grade " << endl;
	cin >> c;

	switch (c)
	{
	case 1:
		cout << "your percentage is " << b << endl;
		if (b >= 80)
		{
			cout << "Excellent result";
		}
		else if (b >= 60 && b < 80)
		{
			cout << "Good Result";
		}
		else if (b >= 35 && b < 60)
		{
			cout << "Can do better";
		}
		else
			cout << "Sorry You Failed in Exam !!!!" << endl;
		break;
	case 2:
		if (b >= 80)
		{
			cout << "You got 'A' Grade ";
		}
		else if (b >= 60 && b < 80)
		{
			cout << "You got 'B' Grade ";
		}
		else if (b >= 35 && b < 60)
		{
			cout << "You got 'C' Grade ";
		}
		else if (b < 35)
		{
			cout << "You got 'D' Grade " << endl;
			cout << "You failed in exam !!!!!";
		}
		break;
	}
	getch();
}

    
    

The code given below can be used for g++/gcc Compiler:-

#include <iostream>
using namespace std;

int main()
{
	int a, b, c;
	cout << "Enter marks out of 150 \n";
	cin >> a;
	b = (a * 100) / 150;
	cout << "For results choose the below options \n";
	cout << "1. Result in percentage \n 2. Result in grade " << endl;
	cin >> c;

	switch (c)
	{
	case 1:
		cout << "your percentage is " << b << endl;
		if (b >= 80)
		{
			cout << "Excellent result";
		}
		else if (b >= 60 && b < 80)
		{
			cout << "Good Result";
		}
		else if (b >= 35 && b < 60)
		{
			cout << "Can do better";
		}
		else
			cout << "Sorry You Failed in Exam !!!!" << endl;
		break;
	case 2:
		if (b >= 80)
		{
			cout << "You got 'A' Grade ";
		}
		else if (b >= 60 && b < 80)
		{
			cout << "You got 'B' Grade ";
		}
		else if (b >= 35 && b < 60)
		{
			cout << "You got 'C' Grade ";
		}
		else if (b < 35)
		{
			cout << "You got 'D' Grade " << endl;
			cout << "You failed in exam !!!!!";
		}
		break;
	}
	return 0;
}

    
    

#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post