Friday, August 7, 2009

BRANCHING STATEMENTS

THE IF STATEMENT
When a C++ programm most choose whether or not to take particular action.You can use the if statement.
The if comes in two forms if and if else
syntax of sample If condition
if(test condition)
stetement
The if statement directs a program to execute a statement block if a test condition true and to skip that statement or block if the conditiond is false.The example is below
include
void main()
{
int a;
cout<<"enter an number";
cin>>a;
if(a>0)
cout<<"a is positive" ;
}

No comments:

Post a Comment