0% found this document useful (0 votes)
24 views

Using Namespace: #Include

The document contains code that takes marks from a user in 5 subjects, calculates the total and average marks, and uses a switch statement to determine the grade based on the average. It outputs the average marks and determined grade. The code declares variables to store marks for each subject, total marks, average marks, accepts input from the user, calculates total and average, and uses a switch statement with conditions on the average to determine and output the grade.

Uploaded by

Nortom Silencer
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Using Namespace: #Include

The document contains code that takes marks from a user in 5 subjects, calculates the total and average marks, and uses a switch statement to determine the grade based on the average. It outputs the average marks and determined grade. The code declares variables to store marks for each subject, total marks, average marks, accepts input from the user, calculates total and average, and uses a switch statement with conditions on the average to determine and output the grade.

Uploaded by

Nortom Silencer
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream>

using namespace std;


int main()
{
//declaration of variables.
int sub1,sub2,sub3, sub4,sub5,total,avg;
//accepting marks from user in each subject
cout << " Enter Programming in C++ Marks: " << endl;
cin >> sub1;
cout << " Enter Software Engineering Marks : " << endl;
cin >> sub2;
cout << " Enter Personal Communication Marks : " << endl;
cin >> sub3;
cout << " Enter Database Application Marks: " << endl;
cin >> sub4;
cout << " Enter Computer Concept Marks: " << endl;
cin >> sub5;
//calculatin sum of marks obtained in each subject
total = (sub1 + sub2 + sub3 + sub4 + sub5);
//calculating the average marks
avg = total / 5;
// starting of if condition for finding out grades of total subjects.
switch (avg){
case 1:{
if ((avg >= 80) && (avg <= 100))
{
cout << " Your Average is: " << avg << endl;
cout << "You Grade is A+ " << endl;
}
break;
}
case 2:{
if ((avg >= 70) && (avg <= 79))
{
cout << " Your Average is: " << avg << endl;
cout << " Your grade is A " << endl;
}
break;
}
case 3:{
if ((avg >= 60) && (avg <= 69))
{
cout << " Your Average is: " << avg << endl;
cout << " Your Grade is B+ " << endl;
}
break;
}
case 4:{

if ((avg >= 50) && (avg <= 59))


{
cout << " Your Average is: " << avg << endl;
cout << " Your Grade is C+ " << endl;
}
break;
}
case 5: {
if ((avg >= 40) && (avg <= 49))
{
cout << " Your Average is: " << avg << endl;
cout << " Your Grade is C- ! " << endl;
}
break;
}
case 6: {
if ((avg >= 30) && (avg <= 39))
{
cout << " Your Average is: " << avg << endl;
cout << " Your Grade is D ! " << endl;
}
break;
}

default:{
if ((avg >= 100) && (avg <= 29))
{
cout << " Your Average is: " << avg << endl;
cout << " Your Grade is F, So you are Fail in the class ! " << endl;
break;
}
}

system("pause");
}

You might also like