[go: up one dir, main page]

0% found this document useful (0 votes)
20 views3 pages

CS101 Assignment 2

The document contains a C++ program that calculates the total and average marks for a student based on their input for various subjects. It assigns a final grade based on the average marks using a predefined grading scale. The program prompts the user for their VU-ID and marks in CS, Math, Pak Studies, and Management, then displays the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views3 pages

CS101 Assignment 2

The document contains a C++ program that calculates the total and average marks for a student based on their input for various subjects. It assigns a final grade based on the average marks using a predefined grading scale. The program prompts the user for their VU-ID and marks in CS, Math, Pak Studies, and Management, then displays the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CS101 ASSIGNMENNT NO.

2
ID: ABDUL HADI E SERVICE

SOLUTION:
CODE
#include <iostream>

#include <string>

using namespace std;

int main() {

string vuID;

int csMarks, mathMarks, pakStudyMarks, mgtMarks;

cout << "Enter your VU-ID: ";

cin >> vuID;

cout << "Enter marks for CS: ";

cin >> csMarks;

cout << "Enter marks for Math: ";

cin >> mathMarks;

cout << "Enter marks for Pak Study: ";

cin >> pakStudyMarks;

cout << "Enter marks for MGT: ";

cin >> mgtMarks;

int totalMarks = csMarks + mathMarks + pakStudyMarks + mgtMarks;


double averageMarks = totalMarks / 4.0;

cout << endl;

cout << "-----------------------------" << endl;

cout << "VU-ID: " << vuID << endl;

cout << "Total Marks: " << totalMarks << endl;

cout << "Average Marks: " << averageMarks << endl;

cout << "Final Grade: ";

if (averageMarks >= 91 && averageMarks <= 100) {

cout << "A+" << endl;

} else if (averageMarks >= 81 && averageMarks < 91) {

cout << "A-" << endl;

} else if (averageMarks >= 71 && averageMarks < 81) {

cout << "B+" << endl;

} else if (averageMarks >= 61 && averageMarks < 71) {

cout << "B" << endl;

} else if (averageMarks >= 51 && averageMarks < 61) {

cout << "C" << endl;

} else if (averageMarks >= 41 && averageMarks < 51) {

cout << "D" << endl;

} else if (averageMarks >= 35 && averageMarks < 41) {

cout << "E" << endl;

} else {

cout << "Fail" << endl;

cout << "-----------------------------" << endl;

return 0;
}

Output Screen Shot:

You might also like