C programming if else statement

C programming if else statement

Conditional Statements in C programming are used to make decisions based on the conditions. Conditional statements execute sequentially when there is no condition around the statements. If you put some condition for a block of statements, the execution flow may change based on the result evaluated by the condition. This process is called decision making in ‘C’ programming.

If-else Statement

The if-else statement is used to run two operations for a single condition. The if-else statement is an extension to the if statement using which, we can perform two different operations, i.e., one is for the correctness of that condition, and the other is for the incorrectness of the condition. Here, we must notice that if and else block cannot be executed simultaneously. Using if-else statement is always preferable since it always invokes an otherwise case with every if condition. The syntax of the if-else statement is given below.

If else Program using c programming:

#include<stdio.h>
int main()
{
int age;
printf("Enter age:");
scanf("%d", &age);

if (age > 18)
{
printf("Adult");
}

else
{
printf("Not adult");
}
return 0;
}

Leap year program in C using if else

BASIC C PROGRAMMING CONCEPT AND PROGRAMS: HELLO WORLD, ADDING TWO INTEGERS, AREA OF SQUARE AND CIRCLE USING VS CODE