Mar 20, 2007

IF condition in C++

IF condition : condition is formed after if keyword in a bracket.
if condition is satisfies then only statement within if block will be executed, if condition fails then statement within IF block will not be executed. if there is only one statement within if block then {} bracket can be omited if there are more than one statement within if block then statements of if block must be in {} brackets. If condition is formed using relational operators relational operators :

#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
int a; // variale declaration
cout <<"enter any number";
cin >> a;

if (a>100)
{
cout << "Hello" <<endl;
}

if (a<100)
{
cout <<"hi" <<endl;
}

if (a==100)
{
cout <<"bye" <<endl;
}

if (a!=100)
{
cout <<"Unique" <<endl;
}

getch();
}

The above program demonstrates if condition using various relational operators

No comments:

Post a Comment

Infolinks In Text Ads

Total Pageviews

Powered by Blogger.

Dont Forget To Follow Us

Blog Archive