24.9k views
3 votes
Write a program whose inputs are three integers, and whose output is the smallest of the three values.Ex: If the input is:7153the output is:3

1 Answer

4 votes

Answer:

The program is written in C++ language and given below in explanation section. All bold faced words are C++ keywords and symbols. Nested if-else decision branch is used to determine smallest number of all three integers. First of all you have input three integers then the program prints smallest integer of all

Step-by-step explanation:

#include <iostream>

using namespace std;

int main() {

int num1,num2,num3;

cout<<"enter first integers"<<endl;

cin>>num1;

cout<<"enter second integers"<<endl;

cin>>num2;

cout<<"enter the third integers"<<endl;

cin>>num3;

if(num1<num2){

if(num1<num3){

cout<<"Smallest integer is "<<num1<<endl;

} else{

cout<<"Smallest integer is "<<num3<<endl;

}

}else {

if(num2<num3){

cout<<"Smallest integer is "<<num2<<endl;

} else{

cout<<"Smallest integer is "<<num3<<endl;

}

}

return 0;

}

User Gsanta
by
4.5k points