Simple IF statement in C++

by Nideesh C on May 7, 2011 · 0 comments

in C++




The simple if statements execute the given block of statements, if the specified conditions become true. This can be given a diagrammatical form as follows:

Simple if statement

 

C++ Syntax:

if(<condition>)

{

Statements;

.

.

.

}

Example:

If (a>b)     //Check if value in a is big

{

.

.

}

If (a==b)   //Check if value in a equal to value in b

{

.

.

}

if((a>b)&&(<a>20))    //Complex condition using &&

{

.

.

}

 

/*———————————————————————–*/

#include<iostream.h>

#include<conio.h>

void main()

{

if (10>20)

cout<<”10 is big”;

if (20>10)

cout<<”20 is big”;

getch();

}

/*—————————————————————————-*/

Output:

20 is big

 

See also  C++ program – To check whether x is greather than y (IF statement)

 

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. if statement in C++
  2. How to add widgets to wordpress footer ? Step by step simple tutorial
  3. C++ Program – Simple & Compound Interest
  4. C++ Program – Simple Interest

Leave a Comment

Previous post:

Next post: