Nested if in C++
If is a type of condition checking in which a condition turns out to be true a block of statements is executed.
Syntax:
// if base_condition is true
// every inside the { } block will be executed
if (base_condition)
{
statement 1...............
statement 2 ..............
}Example
- C++
True
What is Nested If?
When a number of if blocks are present one after another with the same scope (the same scope means under one { } block), then that condition is termed as a Nested if condition. If the first condition is True, we go into the next if condition and the subsequent condition is checked until we get a false condition, and the checking stops.
Syntax:
if base_condition is true control goes to base_condition1
if ( base_condition)
{
// if base_condition is true control goes to base_condition2
if(base_condition1)
{
if(base_condition2)
..........................
..........................
}
}
Example 1:
- C++
a is the largest
Example 2:
- C++
Sandeep Sir is Great!!
Example 3:
- C++
gfg
Example 4:
- C++
No nested if condition is executed
Time complexity: O(1).
Auxiliary space: O(1).
Winter-time is here and so is the time to skill-up! More than 5,000 learners have now completed their journey from basics of DSA to advanced level development programs such as Full-Stack, Backend Development, Data Science.
And why go anywhere else when our DSA to Development: Coding Guide will help you master all this in a few months! Apply now to our DSA to Development Program and our counsellors will connect with you for further guidance & support.

Comments
Post a Comment