C Program to find largest of two numbers using function


In this program, You will learn how to find largest of two numbers using function in c.


10 20 => 20

30 10 => 30


Example: How to find largest of two numbers using function in c

Run it Now
#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("\nLargest is :%d", large);

   return 0;
}

Output:

Enter Two Numbers :10 20
Largest is :20