if else statement
The syntax of the if else is as follows:
if(expression){
/* statement1 */
}else{
/* statement2 */
}
The if else statement is a two way branch: it means do one thing or the other.It used to test a condition, if condition is true then statement1 executed. If the condition is false then statement2 executed.
#include
#include
void main(){
int m;
clrscr();
scanf("Enter a number = %d",m);
if(m > 0){
printf("That number is positive");
}else{
printf("That number is negative or zero");
}
getch();
}
Output
Enter a number = -1
That number is negative or zero