C Program to find maximum between two numbers using if-else statement

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;
  1. In if-else statement first condition is checked.
  2. If the condition is true then the true statement will be executed and the statement x will be executed.
  3. If the condition is false then it will execute the false statement block and then statement x.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply