If Else Statement in C
Here are the implementation of if else statement in C language:
#include <stdio.h>
int main() {
// Declare and initialize the variable num
int num = 10;
// Check if num is greater than 0
if (num > 0) {
// If num is greater than 0, print "Number is positive."
printf("Number is positive.\n");
} else {
// If num is not greater than 0, print "Number is non-positive."
printf("Number is non-positive.\n");
}
return 0;
}
Output
Number is positive.
If Else Statement in Programming
An if else statement in programming is a basic programming technique that allows you to make decisions based on certain conditions. It allows your program to execute different pieces of code depending on whether the specified condition evaluates to true or false. This capability is crucial in building dynamic and functional applications.
Table of Content
- Importance of If Else Statement
- Basic Syntax of If Else Statement
- If Else Statement in C
- If Else Statement in Java
- If Else Statement in Python
- If Else Statement in Javascript