🚀 From Python to placements — 90+ courses & 200+ exams, free on Leyaa.ai →
if else statement
Statements under if executes only, when the given condition is true.
Otherwise, the statements under else will be executed.
When we need to decide either this or that in programming, we should go for if-else statement.
Like,
positive or negative
prime or composite
odd or even etc.
Syntax
Example
if(condition) { //statements } else { //statements }
Pictorial Explanation
Sample Program
Get a number from user and say whether it is zero or non-zero number.
Example
#include<stdio.h> int main() { int num; scanf("%d",&num); if(num == 0) printf("Zero"); else printf("Non-zero"); return 0; }
🚀 One platform. 90+ coding courses. 200+ exams.
From programming fundamentals to competitive exam prep — learn with intelligence, not just content. Free on Leyaa.
Explore Leyaa.ai Free →