Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views2 pages

C++ Program

Uploaded by

bashiran1979
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

C++ Program

Uploaded by

bashiran1979
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream>

#include <algorithm>
using namespace std;
main()
{
string studentID = " BC240200202" ;
string studentname = " MuntahaMudassar";

// student info
cout << "Student ID : " << studentID << endl;
cout << "Student Name : " << studentname << endl;

// taking marks from user and storing in variables


int sub1, sub2, sub3;
do{
cout << "enter the marks of sub1 : " ;
cin >> sub1;
if (sub1 < 0 || sub1 > 100)
{
cout << "invalid marks! please re enter" << endl;
}
}
while (sub1 < 0 || sub1 > 100);
do {
cout << "Enter marks of sub 2: ";
cin >> sub2;
if(sub2 <0 || sub2 > 100)
{
cout << "Invalid marks please re-enter" << endl;
}
}
while (sub2 < 0 || sub2 > 100);
do {
cout << "Enter marks of sub 3: ";
cin >> sub3;
if(sub3 <0 || sub3 > 100)
{
cout << "Invalid marks please re-enter" << endl;
}
}
while (sub3 < 0 || sub3 > 100);
cout << "Marks have been entered. Here is your result: " << endl;

// calculation of avg and obt marks


float obtmarks, average;
obtmarks = sub1 + sub2+ sub3;
cout << "Obtained marks out of 300:" << obtmarks << endl;
average = obtmarks/3.0;
cout << "Average : " << average << endl;

// calculating grade
char grade ;
if(average >= 90)
{
cout << "Grade : " << grade << 'A' << endl;
}
else if(average >= 80)
{
cout << "Grade : " << grade << 'B' << endl;
}
else if(average >= 70)
{
cout << "Grade : " << grade << 'C' << endl;
}
else if(average >= 60)
{
cout << "Grade : " << grade << 'D'<< endl;
}
else
{
cout << "Grade : " << grade << 'F' << endl;
}

// Calculating highest and lowest marks


int highestmarks = max({sub1, sub2, sub3});
int lowestmarks = min({sub1, sub2, sub3});

cout << "Highest marks: " << highestmarks << endl;


cout << "Lowest marks: " << lowestmarks << endl;

return 0;
}

You might also like