In: Computer Science
Write a program
Write a program whose inputs are three integers, and whose output is the smallest of the three values.
Ex: If the input is:
7 15 3
the output is:
3
C++ please
In case of any queries,please comment. I would be very happy to assist all your queries.Please give a Thumps up if you like the answer.
Program
#include <iostream>
using namespace std;
int main()
{
int num1, num2,num3,min; //declare the variables
cout<<"Enter 3 numbers : ";
cin>>num1>>num2>>num3;//get input
from user for num1, num2 and num3
//Find the smallest
if (num1 <= num2 && num1 <= num3)
min=num1;
else if (num2 <= num1 && num2 <=
num3)
min=num2;
else
min=num3;
cout<<"Smallest:
"<<min<<endl;//display the smallest number
return 0;
}
Output
Enter 3 numbers : 7 15 3
Smallest: 3
Program Screenshot