CPP program to find out the largest of three given numbers. The program will accept three numbers and then print the largest of three numbers.
In this program, if statement is used with and (&&) operator.
In this program, if statement is used with and (&&) operator.
#include<iostream.h> #include<conio.h> void main() { clrscr(); int a,b,c; cout << “Enter Value of A : “; cin >> a; cout << “Enter Value of B : “; cin >> b; cout << “Enter Value of C : “; cin >> c; if ( a > b && a > c) cout << endl << “The largest no. is A”; if (b > a && b > c) cout << endl << “The largest no. is B”; if (c > a && c > b) cout << endl << “The largest no. is C”; getch(); }
Output is
Enter Value of A: 34
Enter Value of B: 51
Enter Value of C: 12
The largest no. is B
Enter Value of A: 34
Enter Value of B: 51
Enter Value of C: 12
The largest no. is B