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

2. A student will not be allowed to sit in exam if his/her attendance is less than 75%.

//Take the following input from user.

//Number of class held

//Number 9f class attended and print percentage of class attended.

//Is student allowed to sit in exam or not.

#include<iostream>

using namespace std;

int main()

float a,b,p;

cout<<"\n\tNumber of Class held:";

cin>>a;

cout<<"\n\tNumber of Class Attended:";

cin>>b;

p=(b/a)*100;

cout<<"\n\tPercentage of class attended:"<<p<<"%"<<endl;

if(p>=75)

cout<<"\n\tThe student is allowed to sit in exam";

else

cout<<"\n\tThe student is not allowed to sit in exam";

return 0;

}According to the conditions given in the question,

1. First, the input for held classes and attended classes is taken from the user in the first two lines.
2. After that, the percentage is calculated in the third line.
3. Finally, the percentage is being checked for less than 75 or not, and the statement is printed
accordingly.

You might also like