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

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

Here is the C program in which we have to find the minimum number between two numbers using if-else statement.

#include<stdio.h>
#include<conio.h>
void main()
{         int a,b;
           clrscr();
           printf(“Enter two numbers:”);
           scanf(“%d%d”,&a,&b);
           if(a<b)
           {         printf(“%d is minimum”,a);
           }
           else
           {         printf(“%d is minimum”,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