-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q2.cpp
68 lines (68 loc) · 1.23 KB
/
Q2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include<iostream>
using namespace std;
int main()
{
int a,b,c,avg;
char grade;
cout<<"Enter your marks for the first Subject: ";
cin>>a;
// Enter your marks
while((a>=100) || (a<0))
{
// IF YOUR MARKS ARE INVALID
cout<<"Marks cannot be greater than 100 or less than 0"<<endl;
cout<<"Enter your marks for the first Subject: "<<endl;
cin>>a;
}
// Enter your marks
cout<<"Enter the marks for the second subject: ";
cin>>b;
while((b>=100) || (b<0))
{
// IF YOUR MARKS ARE INVALID
cout<<"Marks cannot be greater than 100 or less than 0"<<endl;
cout<<"Enter the marks for the second subject: "<<endl;
cin>>b;
}
// Enter your marks
cout<<"Enter the marks for the third subject: ";
cin>>c;
while((c>=100) || (c<0))
{
// IF YOUR MARKS ARE INVALID
cout<<"Marks cannot be greater than 100 or less than 0"<<endl;
cout<<"Enter the marks for the third subject: "<<endl;
cin>>c;
}
avg=(a+b+c)/3;
// Take average
// go in only if the average is less than 100
if(avg<=100)
{
// if average is greater than 80 go in this if
if(avg>=80)
grade='A';
else
{
// if your average is less greater than 70
if(avg>=70)
{
grade='B';
}
else
{
// If your averge is greater than 60
if(avg>=60)
{
grade='C';
}
else
//else if your average is less than 60
{
grade='F';
}
}
}
}
cout<<grade<<endl;
}