C Program to find the largest of two numbers using the function
In this program, You will learn how to find the largest of two numbers using a function in C.
if (condition) {
//statement
} else {
//statement
}
Example: How to find the largest of two numbers using a function in c.
#include<stdio.h>
int findLargest(int a, int b) {
if (a > b) {
return a;
} else {
return b;
}
}
int main() {
int a, b, large;
printf("Enter two numbers:");
scanf("%d%d", &a, &b);
large = findLargest(a, b);
printf("Largest is:%d", large);
return 0;
}
Output:
Enter two numbers:8 9
Largest is:9