C program to Find the Largest Number Among Three Numbers

CServer Side ProgrammingProgramming

This program takes the 3 numbers and finds the biggest among all. For this, we will compare the numbers with each other and find out which is the largest

Input: a=2,b=4,c=7
Output:7 Largest Number

Explanation

This program uses only if statement to find the largest number.

Example

#include <iostream>
using namespace std;
int main() {
   int a,b,c;
   a=2,b=4,c=7;
   if(a>b) {
      if(a>c) {
         printf("%d Largest Number ",a);
      } else {
         printf("%d Largest Number ",c);
      }
   } else {
      if(b>c) {
         printf("%d Largest Number ",b);
      } else {
         printf("%d Largest Number ",c);
      }
   }
   return 0;
}
raja
Published on 19-Aug-2019 11:50:53
Advertisements