C program to check given number is maximum or equal between two numbers

Ex: write a C program to check number is maximum, minimum or equal between two numbers. How to write a C program to print number is maximum or equal between two numbers. C program to check number is maximum or equal between two numbers.

Input from user:

Enter the 1st number: 55

Enter the 2nd number: 25

Expected Output:

Number  55 is greater than 25




  Step by step logic of the given program:


1. First we will accept 1st number from user which is 55.


2. After that we will accept 2nd number from user which is 25.

3. After that we use if-else statement or relational operators to check number is maximum or equal.

4. If number 1 means a greater than number 2- b then we will print a is greater than b.

5. If number 2 means b is greater than a then  we print b is greater.

6. Otherwise we will print two numbers are equal.




  C program to check given number is maximum | minimum or equal between two numbers:


#include<stdio.h>
int main()
{
int a,b;

printf("Enter the 1st number\n");
scanf("%d",&a);

printf("Enter the 2nd number\n");
scanf("%d",&b);

if(a>b)
{
printf("Number %d is greater than %d",a,b);
}
else if(b>a)
{
printf("Number %d is greater than %d",b,a);
}
else
{
printf("Given Two numbers are equal\n");
}
return 0;
}


Above program shows the following output:


C program to check given number is maximum | minimum or equal between two numbers




No comments:

Post a Comment

If you have any doubts, please discuss here...👇