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

bc230208086 Assignment Solution

The document is a C++ program submitted by Muhammad Awais for CS-101 Assignment #2. The program takes input of a student's VU ID and marks in 4 subjects, calculates the total and average marks, and determines the final grade based on the average. It outputs the total marks, average marks, and assigned final grade. The program uses if/else statements to assign a letter grade based on the average marks percentage ranges from A+ to Fail.

Uploaded by

Awaisiqbal Awais
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)
33 views3 pages

bc230208086 Assignment Solution

The document is a C++ program submitted by Muhammad Awais for CS-101 Assignment #2. The program takes input of a student's VU ID and marks in 4 subjects, calculates the total and average marks, and determines the final grade based on the average. It outputs the total marks, average marks, and assigned final grade. The program uses if/else statements to assign a letter grade based on the average marks percentage ranges from A+ to Fail.

Uploaded by

Awaisiqbal Awais
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

CS-101

ASSIGNMENT#2

MUHAMMAD AWAIS (bc230208086)

Solution Code:

#include <iostream>

#include <string>

using namespace std;

int main() {

string vuId;

int cs, math, pakStudy, mgt;

// Input portion:

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

cin >> vuId;

cout << "Enter Marks for CS: ";

cin >> cs;

cout << "Enter Marks for Math: ";

cin >> math;

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

cin >> pakStudy;

cout << "Enter Marks for MGT: ";

cin >> mgt;

// Calculation portion:

int totalMarks = cs + math + pakStudy + mgt;

float averageMarks = totalMarks / 4.0;

// Output portion:
cout << "\nTotal Marks: " << totalMarks << endl;

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

// Grading portion:

string finalGrade;

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

finalGrade = "A+";

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

finalGrade = "A-";

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

finalGrade = "B+";

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

finalGrade = "B-";

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

finalGrade = "C";

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

finalGrade = "D";

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

finalGrade = "E";

else if (averageMarks >= 0 && averageMarks < 35)

finalGrade = "Fail";

else

finalGrade = "Invalid";

cout << "Final Grade: " << finalGrade << endl;

return 0;
}

Output Screenchot:

You might also like