C++ Program to find largest of three numbers using function


In this program, You will learn how to find the largest of three numbers using function in C++.


10 20 30 => 30

22 11 10 => 22


Example: How to find the largest of three numbers using function in C++

Run it Now
#include<iostream>
using namespace std;

int checkNumber(int a, int b, int c) {

  if (a > b && a > c)
      return a;
  else if (b > c)
      return b;
  else
      return c;
}

int main() {

  int a, b, c, lar;

  cout << "Enter three Numbers :";
  cin >> a >> b>>c;

  lar = checkNumber(a, b, c);
  cout << "\nLargest is :" << lar;

  return 0;
}

Output:

Enter three Numbers :12 13 11
Largest is :13