What is If-Statements in C ?


If-Statements in C

In this article we will be going to discuss about if statement in Control Statement of C language so,if you want know about this Control statement then stay with article.

This article include:

  • What is If-Statement in C ?
  • Syntax of If Statement and its example.
  • What is nested If-Statement in C ?
  • Syntax of nested If-Statement and its examples.

What is If-Statement in C ?

The If statement is powerful decision making statements and is used to control the flow of execution of statement.it basically a two way decision statement and used in conjunction with an expression.it takes the following form,

if(text expression)

it allow the computer to evaluate the expression first and then, depending on whether the value of the expression (relation and condition) is 'true' (or non-zero) or 'false' (zero).

Syntax of general if statement:

if (text expression)
 {
    statement block;
 }
statement-x;

here if statement block executed when if  have true expression but statement-x is executed in both the condition in true as well as in false statement.

Example of If statement:

example of If statement
If Statement Example

What is Nested If-Statement in C ?

A Nested if Statement is nothing but, it is complex of type of if statement in which one or more if statements are declared in another if statement.

In case of Nested If-statement, inner if statements are dependent on outermost if statement in short if outermost if statement is true then inner if statement will executed other wise not.

Syntax of general Nested if statement:

if (text expression)
 {
     if(text expression)

      statement block;
 }
statement-x;

Example of Nested If statement:

example of Nested If statement
Nested if Statement Example

Conclusion:

In this article we have learned about if and nested if statement in detail with example, I hope after reading this article you have no any doubt remaining in this topic but if you any doubt then feel free comment below.
Post a Comment (0)
Previous Post Next Post