Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Virtual University of Pakistan

ASSIGNMENT NO. 3
Subject: Computer Science

Course Code: CS101

Name: Ammara Shahzadi

Student Id: Bc210404690


Write a C++ program that calculates the total marks and average marks obtained by a student in five
subjects and also computes the division based on the average marks. You are required to enter the marks
for each subject out of 100 marks. The output screen should show your name and student id (VU ID),
obtained marks, average marks, and division as shown in the output diagram (given below):

Use the division system mentioned below to compute the Division using the if-else structure.

Greater than or equal to 60 First Division

Greater than or equal to 45 but less than 60 Second Division

Greater than or equal to 33 but less than 45 Third Division

And in case marks are less than 33% Fail

The output of this program should be as follows:


Answer:
#include <iostream>

#include <cstdlib>

using namespace std;

int main()

int s1,s2,s3,s4,s5,obt;

float avg;

string d;

cout<<"Enter 1st subject marks: "<<endl;


cin>>s1;

cout<<"Enter 2nd subject marks: "<<endl;

cin>>s2;

cout<<"Enter 3rd subject marks: "<<endl;

cin>>s3;

cout<<"Enter 4th subject marks: "<<endl;

cin>>s4;

cout<<"Enter 5th subject marks: "<<endl;

cin>>s5;

system("clear");

obt= s1+s2+s3+s4+s5;

avg= obt/5;

if(avg>=60)

d="1st";

else if(avg>=45)

d="2nd";

else if(avg>=33)

d="3rd";
else

d="fail";

cout<<"Student Name : Ammara Shahzadi"<<endl;

cout<<"Student ID : Bc210404690"<<endl;

cout<<"obtained marks : "<< obt<<"/500" <<endl;

cout<<"Average marks : " << avg<<" % " <<endl;

cout<<"Division : " << d<<endl;

return 0;

You might also like