Write a program to find the greatest of three numbers in c++
Answers
Answered by
3
#include <iostream>
using namespace std;
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;
}
return 0;
}
Answered by
6
Answer:
#include<constream.h>
void main ();
{
clrscr();
int a, b, c;
cout<<"\nEnter first number:";
cin>>a;
cout<<"\nEnter second number:";
cin>>b;
cout<<"\nEnter third number:";
cin>>c;
cout<<"\nLargest number=";
if(a>b&&a>c)
{
cout<<a;
}
elseif(b>a&&b>c)
{
cout<<b;
}
else
{
cout<<c;
}
getch();
}
Similar questions