C program to Find the Largest Number Among Three Numbers



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; }
Updated on: 2019-08-19T11:50:53+05:30

798 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements