if-else condition
#include <iostream>
using namespace std;
int main ()
{
int a = 50;
// check for condition
if( a > 100 )
{
// if condition is true then print the following
cout<< " If Condition is satisfied ";
cout << "a is greater than 100" << endl;
}
else
{
// if condition is false then print the following
cout<< " If Condition is not satisfied ";
cout << "a is not greater than 100" << endl;
}
cout << "value of a is : " << a << endl;
return 0;
}
Output:
If Condition is not satisfied
a is not greater than 100
value of a is : 50
#include <iostream>
using namespace std;
int main ()
{
int a = 50;
// check for condition
if( a > 100 )
{
// if condition is true then print the following
cout<< " If Condition is satisfied ";
cout << "a is greater than 100" << endl;
}
else
{
// if condition is false then print the following
cout<< " If Condition is not satisfied ";
cout << "a is not greater than 100" << endl;
}
cout << "value of a is : " << a << endl;
return 0;
}
Output:
If Condition is not satisfied
a is not greater than 100
value of a is : 50