Answer:
#include<iostream>
using namespace std;
int main(){
int n1, n2, n3;
cout<<"Enter any three numbers: ";
cin>>n1>>n2>>n3;
if(n1>=n2 && n1>=n3){
cout<<n1<<" is the maximum";}
else if(n2>=n1 && n2>=n3){
cout<<n2<<" is the maximum";}
else{
cout<<n3<<" is the maximum";}
return 0;
}
Explanation:
The program is written in C++ and to write this program, I assumed the three variables are integers. You can change from integer to double or float, if you wish.
This line declares n1, n2 and n3 as integers
int n1, n2, n3;
This line prompts user for three numbers
cout<<"Enter any three numbers: ";
This line gets user input for the three numbers
cin>>n1>>n2>>n3;
This if condition checks if n1 is the maximum and prints n1 as the maximum, if true
<em>if(n1>=n2 && n1>=n3){</em>
<em>cout<<n1<<" is the maximum";}</em>
This else if condition checks if n2 is the maximum and prints n2 as the maximum, if true
<em>else if(n2>=n1 && n2>=n3){</em>
<em>cout<<n2<<" is the maximum";}</em>
If the above conditions are false, then n3 is the maximum and this condition prints n3 as the maximum
<em>else{</em>
<em>cout<<n3<<" is the maximum";}</em>
return 0;