Write a program to find bigest of two numbers. Use if... Then... Else
Answers
Answered by
0
The Concept to find the biggest of the given two numbers is as follows,
- Basically using If , Then and Else we can write a C program to find which is the largest. Now suppose those are n1 and n2 . So there are 3 cases . If n1 > n2 then n1 will be largest otherwise if n2>n1 then n2 will be the largest .The last case is if n1= n2 then those are equal ,
- So the C program will be,
#include <stdio.h>
int main()
{
int num1, num2;
// which is basically asking user to enter the two numbers
printf("Now enter 2 different values here\n");
// Read those entered 2 numbers from the user
scanf("%d %d", &n1, &n2);
if(n1 > n2)
{
printf("%d is the Largest number\n", n1);
}
else if (n1 > n1)
{
printf("%d is the Largest number \n", n2);
}
else
{
printf("Both of 2 numbers are Equal\n");
}
return 0;
} .
Similar questions
Math,
1 day ago
Computer Science,
3 days ago
Hindi,
3 days ago
Chemistry,
8 months ago
Math,
8 months ago