This is the C Program to find the largest among three numbers The program first declares four integer variables – num1, num2, num3 and largest.
- It then prompts the user to enter three numbers using the
printf
andscanf
functions. - Using the
if-else
statements, the program compares the three numbers to determine the largest number among them. - Finally, the program uses the
printf
function to output the largest number to the user.
#include <studio.h>
int main() {
int num1, num2, num3, largest;
printf("Enter three numbers: ");
scanf("%d %d %d", &num1, &num2, &num3);
if (num1 >= num2 && num1 >= num3)
largest = num1;
else if (num2 >= num1 && num2 >= num3)
largest = num2;
else
largest = num3;
printf("Largest number is %d", largest);
return 0;
}
output
Enter three numbers: 10 15 20
Largest number is 20


[…] to 100. We will delve into their characteristics, reveal their secrets, and provide you with a Java program to generate prime numbers efficiently using the Sieve of Eratosthenes algorithm. Let’s dive […]