Home » C Program to Find the Largest of Three Numbers Using More Than One Function

C Program to Find the Largest of Three Numbers Using More Than One Function

Learn about C Program to Find the Largest of Three Numbers Using More Than One Function in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Contents

C Program to Find the Largest of Three Numbers Using More Than One Function

Program:

#include<stdio.h>

float input();
float large(float a, float b, float c);
void display(float max);

int main()
{
   float num1, num2, num3, largest;

   num1 = input();
   num2 = input();
   num3 = input();

   largest = large(num1, num2, num3);
   display(largest);

   return 0;
}

float input()
{
   float n;
   printf("Enter number: ");
   scanf("%f", &n);
   return n;
}

void display(float max)
{
   printf("Largest number = %.2f",max);
}

float large(float a, float b, float c)
{
   if(a>=b && a>=c) return a;
   else if(b>=a && b>=c) return b;
   else return c;
}

Output:

Enter number: 5
Enter number: 3
Enter number: 2
Largest number = 5.00

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
C Program to Find the Largest of Three Numbers Using Functions
C Program to Find Sum of N Numbers Using more than one Function