write the algorithm to find the minimum number out of three number
Answers
Answered by
0
#include <iostream>
using namespace std;
int main() {
cout<<"enter three number\n";
int a,b,c;
cin>>a;
cin>>b;
cin>>c;
cout<<"first enter number: "<<a<<endl;
cout<<"second enter number: "<<b<<endl;
cout<<"third enter number: "<<c<<endl;
int smallest;
smallest=a<b?a:b;
smallest=smallest<c?smallest:c;
cout<<"smallest out of three :"<<smallest;
return 0;
}
___________________________________
1. take input of three number from user(says a,
b, c).
2. make a variable smallest.
3. check min value out of any two user number(a<b, b<a) and store out in smallest..
4. now compare(find minimum ) between the smallest and third variable(smallest<c, c<smallest) the new smaller value by comparison store in variable smallest..
Similar questions