Header Responsive Ads

If Statement

if statement in c++

In C/C++, the statement is used to execute a particular block of code if a certain condition is true. Three types of statements are used in C/C++ 
  • If statement
  • If-else statement
  • Switch statement

Syntax of if statement

    body code

Here body code will only be executed if the condition is true

The below code will check a variable number whether less than 5 or not. As the number is 4 so condition will be true and the body code will be executed. In the body, the output is displayed to users that number is less than 5.

int number = 4;
if(number < 5)
 cout<<"Less then 5";

Write a Program to use if statement in C/C++

if statement
If statement

if statement output
If statement output

Post a Comment

Previous Post Next Post

In Article Ads 1 Before Post

In Article Ads 2 After Post