C program to find the largest among three numbers

Estimated read time 2 min read



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 and scanf 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

C program to find the largest among three numbers
C program to find the largest among three numbers
output of C program to find the largest among three numbers
output of C program
admin https://study-from-here.com

Digital Marketing Consultants and Social Media Marketing Expert with over 3 years of rich experience in various Branding, Promotions, business directories, On pages and off page optimization, Link building Advertising, Research, paid advertisement, content writing and marketing

You May Also Like

More From Author

1 Comment

Add yours

+ Leave a Comment