Write a program to find the largest among 2 numbers, 3 numbers.
#include<stdio.h>
#include<conio.h>
int main(){
int num1, num2;
printf("Please Enter Two different values\n");
scanf("%d %d", &num1, &num2);
if(num1 > num2){
printf("%d is Largest\n", num1);
}
else if (num2 > num1){
printf("%d is Largest\n", num2);
}
else{
printf("Both are Equal\n");
}
return 0;
}
Output:
Please Enter Two different values
7 3
7 is Largest
#include<stdio.h>
#include<conio.h>
int main()
{
double n1, n2, n3;
printf("Enter three numbers: ");
scanf("%lf %lf %lf", &n1, &n2, &n3);
if (n1 >= n2 && n1 >= n3)
printf("%.2lf is the largest number.", n1);
else if (n2 >= n1 && n2 >= n3)
printf("%.2lf is the largest number.", n2);
else
printf("%.2lf is the largest number.", n3);
return 0;
}
Output:
Enter three numbers: 12 10 20
20.00 is the largest number
Read: Program to find the given year is a leap year using C
. We will provide you updates daily.