Computer Science, asked by Sudeep4666, 11 months ago

Write a program to find the greatest of three numbers in c++

Answers

Answered by klbmbmhtp9wa5v
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 Soñador
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