Home > Backend Development > C++ > body text

C program: find the largest number among three numbers

PHPz
Release: 2023-08-30 14:25:08
forward
1749 people have browsed it

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
Copy after login

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;
}
Copy after login

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!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template