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

CS101 Assignment No. 2

The document is an assignment submission by Muhammad Hanzala Asif for CS101-Introduction to Computing. It includes a C++ program that takes user input for marks in various subjects, calculates total and average marks, and assigns a grade based on the average. The program covers basic input/output operations and conditional statements for grading.

Uploaded by

Hanzala Asif
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)
5 views

CS101 Assignment No. 2

The document is an assignment submission by Muhammad Hanzala Asif for CS101-Introduction to Computing. It includes a C++ program that takes user input for marks in various subjects, calculates total and average marks, and assigns a grade based on the average. The program covers basic input/output operations and conditional statements for grading.

Uploaded by

Hanzala Asif
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/ 5

ASSIGNMENT NUMBER 2

Name :- Muhammad Hanzala Asif


Subject :- CS101-Introduction to
Computing
VU ID :- bc230208397
Semester :- 1st (Spring 2023)

Question No. 1
Answer
Input
#include <iostream>
#include <string>
using namespace std;
int main() {
string vuId;
int cs, math, pakStudy, mgt;

// For taking input from user


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;

// Making Calculations
int totalMarks = cs + math + pakStudy + mgt;
float averageMarks = totalMarks / 4.0;

// For gaining output


cout << "\nTotal Marks: " << totalMarks << endl;
cout << "Average Marks: " << averageMarks << endl;

// For obtaining grades


string Grade;
if (averageMarks >= 91 && averageMarks <= 100)
Grade = "A+";
else if (averageMarks >= 81 && averageMarks < 91)
Grade = "A-";
else if (averageMarks >= 71 && averageMarks < 81)
Grade = "B+";
else if (averageMarks >= 61 && averageMarks < 71)
Grade = "B-";
else if (averageMarks >= 51 && averageMarks < 61)
Grade = "C";
else if (averageMarks >= 41 && averageMarks < 51)

Grade = "D";
else if (averageMarks >= 35 && averageMarks < 41)
Grade = "E";
else if (averageMarks >= 0 && averageMarks < 35)
Grade = "Fail";
else
Grade = "Invalid";
cout << "Grade: " << Grade << endl;
return 0;
}

Ouput

You might also like