Write a program to find the largest among three numbers using user defined function.

Share

source code

#include <stdio.h>
#include <conio.h>
void compare(int,int,int);
int main(){
    
    printf("Enter the three numbers:");
    int x,y,z;
    scanf("%d %d %d",&x,&y,&z);
    compare(x,y,z);
    return 0;
}
void compare(int a,int b,int c){
    if (a>b && a>c)
    {
       printf("largest number is:%d",a);
    }
    else if (b>a && b>c)
    {
       printf("largest number is:%d",b);
    }
    else{
        printf("largest number is:%d",c);
    }
    
} 

output

Share
%d bloggers like this: