Program to find Greatest of a Three Numbers in C++
Following is the program to find greatest of three numbers.
#include<iostream.h>
#include<conio.h>
int main()
{
float n1, n2, n3;
cout << "Enter three numbers: ";
cin >> n1 >> n2 >> n3;
if (n1 >= n2 && n1 >= n3)
{
cout << "Largest number: " << n1;
}
if(n2 >= n1 && n2 >= n3)
{
cout << "Largest number: " << n2;
}
if(n3 >= n1 && n3 >= n2)
{
cout << "Largest number: " << n3;
}
getch();
return 0;
}
Enter three numbers: 34 45 56
Largest number: 56