# What is IF Statement?

IF Statement Programming Exercise Part-1

IF Statement Programming Exercise Part-2

IF Statement Programming Exercise Part-3

Conditional Structure Programming Exercise P-4

Conditional Structure Programming Exercise P-5

Conditional Structure Programming Exercise P-6

#### Write a program that inputs marks of three subjects of a student. If average marks are more than 50, it displays messages “Your average marks are more than 50” and “Congratulation to you” in two lines using two output statements. Use simple ‘if’ statement in the program.

```#include"iostream"
using namespace std;
main()
{
int sub1, sub2, sub3;
float avg;
cout<<"Enter marks of first subject ? ";
cin>>sub1;
cout<<"Enter marks of second subject ? ";
cin>>sub2;
cout<<"Enter marks of third subject ? ";
cin>>sub3;
avg = (sub1+sub2+sub3)/3.0;
if(avg > 50)
{
cout<<"Your average marks are more than 50"<<endl;
cout<<"Congratulation to you"<<endl;
}
cout<<"End of the program";
}

```

#### Write a program that inputs two numbers and finds out whether both numbers are equal.

```main()
{
int x, y;
cout<<"Enter first number ? ";
cin>>x;
cout<<"Enter second number ? ";
cin>>y;
if(x == y)
{
cout<<"Both numbers are equal\n";
cout<<"End of the program";
}
}```

#### Write a program that inputs a character and determines whether it is a lowercaseletter or not using a simple ‘if’ statements.

```
main()
{
char ch;
cout<<"Enter a character ? ";
cin>>ch;
if(ch>='a' && ch<='z')
{
cout<<"Entered character is lowercase letter"<<endl;
}
else
{
cout<<”Entered character is upper case”;

}```

#### Write a program that inputs two values and finds out the greater value using if-elsestructure and displays result on screen.

```main()
{
int a, b;
cout<<"Enter Two Numbers = ";
cin>>a>>b;
if (a>b)
{
cout<<"First value is greater"<<endl;
}
else
{
cout<<"Second value is greater"<<endl;
}
}```