If-else statement, All programmers are familier with if-else statement.
In C if-else statement is used to perform operations based on your specific condition. The specified operation in the block is executed if and only if the given condition is true and condition is false then control goes to else part.
Syntax.
if(expression){
//code to be executed at true condition } else{ //code to be executed at false condition }
Program
#include<stdio.h>
int main(){
int number=0;
printf('Enter a number:');
scanf('%d',&number);
if(number%2==0){
printf('%d is even number',number);
}else{ printf('%d is odd number',number); } return 0;
}
Output:
Enter a number: 5 5 is even number
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
If-else statement, All programmers are familier with if-else statement.
In C if-else statement is used to perform operations based on your specific condition. The specified operation in the block is executed if and only if the given condition is true and condition is false then control goes to else part.
Syntax.
if(expression){ //code to be executed at true condition} else{
//code to be executed at false condition
}
Program
Output: