Conditional Programming in C++

#### 1. Write a C++ to find the greatest among two numbers

```#include<iostream>
using namespace std;
int main() {
int a,b;
cout<<"Enter value for A: ";
cin>>a;
cout<<"Enter value for B: ";
cin>>b;
if(a>b) {
cout<<"A is Greater";
}
else {
cout<<"B is Greater";
}
return 0;
}```
OUTPUT
```Enter value for A: 12
Enter value for B: 14
B is Greater```

#### 2. Write a C++ to find greatest among three numbers

```#include<iostream>
using namespace std;
int main() {
int a,b,c;
cout<<"Enter Values for A,B & C ";
cin>>a>>b>>c;
if(a>b && a>c) {
cout<<"A is greatest ";
}
else if(b>c) {
cout<<"B is greatest ";
}
else {
cout<<"C is greatest ";
}
return 0;
}
```
OUTPUT
```Enter Values for A,B & C 10 29 20
B is greatest```

#### 3. Write a C++ to find greatest among three numbers using nested if else.

```#include<iostream>
using namespace std;
int main() {
int a,b,c;
cout<<"Enter Values for A,B & C ";
cin>>a>>b>>c;
if(a>b) {
if(a>c)
cout<<"A is greatest";
else
cout<<"C is greatest";
}
else{
if(b>c)
cout<<"B is greatest";
else
cout<<"C is greatest";
}
return 0;
}
```
OUTPUT
```Enter Values for A,B & C 10 50 30
B is greatest```

#### 4. Write a C++ to check a given number is even or odd

```#include<iostream>
using namespace std;
int main() {
int a;
cout<<"Enter Value for A: ";
cin>>a;
if(a%2==0)
cout<< a<<" IS EVEN NO.\n";
else
cout<< a<<" IS ODD NO.\n";
return 0;
}
```
OUTPUT
```Enter Value for A: 12
12 IS EVEN NO.```

#### 5. Write a C++ to check the alphabet is vowel or not.

```#include<iostream>
using namespace std;
int main() {
char a;
cout<<"Enter a Character: ";
cin>>a;
if(a=='a' ||a=='e' ||a=='i' ||a=='o' ||a=='u') {
cout<<"Character is vowel \n";
}
else if(a=='A' ||a=='E' ||a=='I'||a=='O' ||a=='U') {
cout<<"Character is vowel \n";
}
else {
cout<<"Character is NOT vowel \n";
}
return 0;
}
```
OUTPUT
```Enter a Character: E
Character is vowel```

#### 6. Write a C++ to ask user to enter marks of 5 subjects and calculate the percentage then print GRADE according to marks in percentage

```#include<iostream>
using namespace std;
int main() {
int m1,m2,m3,m4,m5;
float per;
cout<<"Enter Marks Subject 1: ";
cin>>m1;
cout<<"Enter Marks Subject 2: ";
cin>>m2;
cout<<"Enter Marks Subject 3: ";
cin>>m3;
cout<<"Enter Marks Subject 4: ";
cin>>m4;
cout<<"Enter Marks Subject 5: ";
cin>>m5;
per = (m1+m2+m3+m4+m5)/5.0;
cout<<"Your Marks % is "<< per<< endl;
if(per>=80)
else if(per>= 70)
else if(per>= 60)
else if(per>= 50)
else
return 0;
}
```
OUTPUT
```Enter Marks Subject 1: 90
Enter Marks Subject 2: 91
Enter Marks Subject 3: 92
Enter Marks Subject 4: 92
Enter Marks Subject 5: 90
Your Marks % is 91

#### 7. Write a C++ to print DAY according to user input for day count

```#include<iostream>
using namespace std;
int main() {
int a;
cout<<"Enter Day Number: ";
cin>>a;
switch(a) {
case 1:
cout<<"Day is Monday\n";
break;
case 2:
cout<<"Day is Tuesday\n";
break;
case 3:
cout<<"Day is Wednesday\n";
break;
case 4:
cout<<"Day is Thursday\n";
break;
case 5:
cout<<"Day is Friday\n";
break;
case 6:
cout<<"Day is Saturday\n";
break;
case 7:
cout<<"Day is Sunday\n";
break;
default:
cout<<"Wrong Choice\n";
}
return 0;
}

```
OUTPUT
```Enter Day Number: 4
Day is Thursday
```

#### CONTACT DETAILS

info@prowessapps.in
(8AM to 10PM):

+91-8527238801 , +91-9451396824