Nested IF statement in C program

Asked By 10 points N/A Posted on -
qa-featured

What is a nested IF statement and what does it do to help the programmer produce a good output?

SHARE
Best Answer by Lesten Pasio
Answered By 5 points N/A #103217

Nested IF statement in C program

qa-featured

Hi Noel, C is a programming language that is developed at AT & T's Bell Laboratories of USA in 1972 by Dennis Ritchie who Designed and written it completely and C became popular due to its ease of use and advantages.

Coming to If statements we generally use if condition for checking the decision made by the condition and the syntax for if is follows as given by..

if(condition)

statement;

Here condition refers to " 5>10 " then if the statement is true then it returns print statement and if not satisfied then else is used to print statement next to else if not satisfied.

Example is defined as..

if(5>10)

{

printf("good");

}

else

{

printf("bad");

}

Here the output will be printed as bad as the condition is not satisfied and if it is " 5<10" then it will be printed as good as the condition is satisfied.

Thank You.

Best Answer
Best Answer
Answered By 40 points N/A #103218

Nested IF statement in C program

qa-featured

Hi there , 

It seems you need details on what is nested if s . 

A nested if is a special kind of if that has another if in its body or in inside its else body.

An example of the nested if is as follows :- 

if(expression1 ) 

{

:

if(expression2 ) 

statement 1 ;

else 

statement 2 ;

}

else 

body of else ;

Nested ifs can be a little bit of confusing but with little logic and pure thinking you can handle that in ease. All you need is concentration. Nested ifs can be used for a lot variety of programs like writing a code to test a number whether it is positive or negative or zero.

Good luck

Answered By 10 points N/A #103219

Nested IF statement in C program

qa-featured

Thank you for the explanations given about the C language.

Thanks Hoting Gracia. Thanks Lesten Pasio.

Thanks TechyV.

Related Questions