Home  >  Article  >  Backend Development  >  C program: find the largest number among three numbers

C program: find the largest number among three numbers

PHPz
PHPzforward
2023-08-30 14:25:081566browse

C program: find the largest number among three numbers

This program takes 3 numbers and finds the largest one. To do this we will compare the numbers with each other and find the largest

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

Instructions

This program uses only if statement to find the maximum 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;
}

The above is the detailed content of C program: find the largest number among three numbers. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete