if else in C

if else conditions in C programming. Actually, "if else" statement plays a very important role in decision making

if else statement in C programming is an extension of simple if statement. It has one condition and two possible decisions.

if Statement Syntax

The working of if else statement is very simple, In the above syntax if test condition is true then true block will be executed and if test condition if false then false-block will be executed.

Top points about if else statement in C

  • If condition/expression is TRUE then true-block ( if block ) will run.
  • If condition/expression is FALSE then false-block ( else block ) will run.
  • In if else condition only one block will run based on TRUE and FALSE, not both.
  • if else is also called as " one condition two decision statement ".
  • It is used when there is one condition to check and have to select one statement out of two.
c if else block diagram

C if else - Examples

Example

Write a program in C to find out the greater number out of two numbers using if else statement.

Output

Example

Find out the given number is even number or odd number

Output

In the next chapter, you will study the nested form of if else statement which is more interesting so let's click next button.

Email Us: advertise@gdatamart.com

Donate Us: Support to GDATAMART

© 2023 GDATAMART.COM (All Rights Reserved)