|
|
Tutorials

Cpp

|
Topic |
How is an If statement, Conditional Branching used in C++?
|
|
Explanation |
|
If statement is a conditional branching statement used to execute a set of code when the condition is true. This belongs to control structures.
Syntax:
if(expression)
{ Statements }
Example:
#include <iostream.h>
using namespace std;
void main()
{
int a=100;
int b=200;
if (b>a)
{
cout << "B is greater than A";
}
}
|
Result:
B is greater than A
In the above example the condition in the if statement returns a true value so the text given below
is displayed.
This is how, conditional branching of program execution can be performed.
|
| Note |
C++ is one of the most used programming languages in the world. Also known as "C with Classes".
Hope you enjoy this tutorial. Do send your feedback or suggestions on this C++ tutorial. This is a copyright content.
|
|
|
|