by Dinesh Thakur Category: Function and Pointer

It accepts three parameters  x,y, and z, each of type double and returns a value of type double.

A local variable max is used to hold the maximum of the three given numbers. Initially, the larger of x and y is stored in variable max using an if-else statement. Then the value of z is assigned to max if it is greater than max. Finally, the value of max is returned. A function to return the maximum of three numbers is given below.

#include <stdio.h>

double max3(double x,double y,double z);

void main ()


      double i;

      double a,b,c;


      printf("Enter the value of x,y,z:\n");


      i= max3(a,b,c) ;




double max3(double x,double y,double z)


    double max;

    if (x > y)

       max = x;

    else max = y;

    if (z > max)

       max = z;

       return max;


       C Program function to return the maximum of three numbers

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles