Program to calculate the average of 3 marks. If the average is more than or equal to 60 display “PASS” otherwise display “FAIL”
more than or equal to 60 display “PASS” otherwise display
“FAIL”.
Note: Here you didn't mention any programming language so we are making the program in the C++ programming language.
Introduction of the Program:
The C++ program takes 3 subject marks from the user as input then the program calculates the average of the marks and if the average is more than or equal to 60 then the program displays PASS otherwise the program displays the FAIL.
Source code of the Program: save the below code as main.cpp
//main.cpp
#include<iostream> //header files for cin/cout functions
using namespace std;
//start of main function
int main()
{
//variable declaartion
int num1,num2,num3;
double avg;
cout<<"Enter 3 subject marks : "<<endl;
//taking three subject marks from the user
cin>>num1>>num2>>num3;
//calculating the average
avg=(num1+num2+num3)/3.0;
//displaying the average marks
cout<<"Average of the Marks is : "<<avg<<endl;
//checking condition to display PASS or FAIL
if(avg>=60.0){
cout<<"\nPASS"<<endl;
}else
cout<<"\nFAIL"<<endl;
} //end of main function
Step by step
Solved in 3 steps with 1 images