Simple if statement in C++

Simple if statement in C++

Simple if statement in C language is a very powerful decision making statement and it is used to control the flow of execution of statements.

There are four types of if statement:

Simple if statement in C++

 In simple if statement, there is only one Condition and depending upon the Condition, a particular set of statements will be executed. The syntax of simple if statement is:

Test-Condition is conditional expression. If it is true, Block  of statements referred as Statement-Block gets executed. otherwise Statement-Block will not execute. Here Statement-Block is a set of valid C++ statements .

Program to demonstrate simple if statement in C++.
using namespace std;
int main()
 int n=10;
   cout<<“number is +ve”;

In the above program, value of variable n is 10. 

Condition n>0 is true so  cout<<“number is +ve” as well as  cout<<“\nBye” both would be executed.

Spread the love
Lesson tags: if in C++, if statement in c, program of simple if statement in C++, simple if statement in c, syntax of if statement in C++, types of if statement in c
Back to: C++ Programming Notes
Spread the love