Showing posts with label if statement example. Show all posts
Showing posts with label if statement example. Show all posts

Saturday, 13 July 2013

if statement syntax

C++ "if" statement contains following elements.
  • Test expression
  • if body

Figure: if statement

The operation of "if" statement is explained by using flow chart.

Figure: if statement flow chart

Monday, 8 July 2013

IF Statement tutorial in C++

#include<iostream.h>
#include<conio.h>
void main()
{
    clrscr() ;        //to clear output screen at the beginning
    int  i ;        //decleration   
    cout<<"Enter any number: ";
    cin>>i ;
   
    if( i > 50 )
    {
        cout<<"The number is greater than 50 ";
        cout<<endl;
    }
    getch();
}