0% found this document useful (0 votes)
5 views1 page

Find the Largest of Three Numbers

The document contains a C program that defines a function to determine the largest of three numbers. It prompts the user to input three integers and then calls the function to find and print the largest number. However, there is a logical error in the function that prevents it from correctly identifying the largest number when all three are equal or when 'c' is the largest.

Uploaded by

jarrdeja
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Find the Largest of Three Numbers

The document contains a C program that defines a function to determine the largest of three numbers. It prompts the user to input three integers and then calls the function to find and print the largest number. However, there is a logical error in the function that prevents it from correctly identifying the largest number when all three are equal or when 'c' is the largest.

Uploaded by

jarrdeja
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#include<stdio.

h>

void Largest(int a, int b, int c){//a, b, and c -- formal parameters (shown in


function definition.
int largest;
if (a > b){
largest = a;
}
else if (b > a)
{
largest = b;
}
else if (c > largest)
{
largest = c;
}
printf ("The largest number is %d", largest);
}
int main()
{
int n1,n2,n3,largest;

printf("Enter three numbers: \n");


scanf("%i%i%i", &n1,&n2,&n3);

Largest(n1,n2,n3);//function call

You might also like