# Write a program in C++ and Python to find the greatest number among the three numbers

By | September 21, 2019

In this program we will code to find out the greatest number among 3 numbers, here in this code first we will ask the user to enter 3 numbers then we will display the greatest one.

### C++

```#include<iostream.h>
#include< conio.h>
#include<stdio.h>
#include<math.h>

void main()
{
clrscr();
int num_1,num_2,num_3;
cout<<"Enter the first number: ";
cin>>num_1;
cout<<"Enter the second number: ";
cin>>num_2;
cout<<"Enter the third number: ";
cin>>num_3;
if(num_1 >= num_2 && num_1>=num_3)
cout<<"The greatest number is: "<<num_1;
if(num_2 >=num_1 && num_2>=num_3)
cout<<"The greatest number is: "<<num_2;
else
cout<<"The greatest number is: " <<num_3;
getch();
}```

Output:

```Enter the first number: 12
Enter the second number: 23
Enter the third number: 54
The greatest number is: 54```

### Python:

```arr=[]
num_1= int(input("Enter the first number: "))
arr.append(num_1)
num_2= int(input("Enter the second number: "))
arr.append(num_2)
num_3= int(input("Enter the third number: "))
arr.append(num_3)
print("The greatest number is:",max(arr))```

Output:

```Enter the first number: 45
Enter the second number: 78
Enter the third number: 23
The greatest number is: 78```

People Also Practicing: