C Program to find maximum between two numbers using if-else statement
Here is the C program to find maximum between two numbers using the if-else statement
#include<stdio.h>
#include<conio.h>
void main()
{ int a,b;
clrscr();
printf(“Enter value of a:”);
scanf(“%d”,&a);
printf(“Enter value of b:”);
scanf(“%d”,&b);
if(a>b)
{ printf(“%d is maximum”,a);
}
else
{ printf(“%d is maximum”,b);
}
getch();
}
Output
The general syntax of if-else statement is :
if (condition)
{ true statement ;
}
else
{ false statement;
}
statement x;
- In if-else statement first condition is checked.
- If the condition is true then the true statement will be executed and the statement x will be executed.
- If the condition is false then it will execute the false statement block and then statement x.