write a C++ program that asks the user to enter 4 integer numbers then use
if ….. elseif ….. elseif ….. else
to find the smallest number then display it.
#source code:
#include <iostream>
using namespace std;
int main(){
int a1,a2,a3,a4;
cout<<"Enter 4 Numbers give space:";
cin>>a1;
cin>>a2;
cin>>a3;
cin>>a4;
int snm;
if(a1<=a2 && a1<=a3 && a1<=a4){
snm=a1;
}else if(a2<=a1 && a2<=a3 && a2<=a4){
snm=a2;
}else if(a3<=a1 && a3<=a2 && a3<=a4){
snm=a3;
}else{
snm=a4;
}
cout<<"Smallest Number:"<<snm<<endl;
return 0;
}
#if you have any doubt or more information needed comment below..i will respond as possible as soon..thanks..
Get Answers For Free
Most questions answered within 1 hours.