- 1

If statement C++

please could someone write down the code for this question: write a c++ program to find the maximim and minimum of 5 numbers (a b c d e) using IF statemnet... i will be glad if u show ur responses..thanks

5th Jul 2017, 7:20 PM
RiGeL
RiGeL - avatar
9 Réponses
+ 1
Ok cool, I'll explain in words, then see if you can make that into code. First, set up a max variable and a min variable. Then set them both equal to the first number, a. Then, for each other number: Check if it is larger than max. If it is, set max equal to it. Check if it is smaller than min. If it is, set min equal to it.
5th Jul 2017, 7:50 PM
zaqqwerty
+ 3
Show us what you already tried. If you haven't tried anything, me holding your hand won't be of any benefit of you.
5th Jul 2017, 7:24 PM
AgentSmith
+ 3
Won't matter since he isn't allowed to use loops. It's simple use of if statements, but I feel like he is just wanting us to do his challenges without him even attempting to solve his problem first. That's why it's only question and no code posted from where he ran into issue.
5th Jul 2017, 7:30 PM
Taco Jack
+ 2
no it is not given in arrays😊
5th Jul 2017, 7:36 PM
RiGeL
RiGeL - avatar
+ 2
#zaqqwerty thank you for the idea, i will try it👍
5th Jul 2017, 9:15 PM
RiGeL
RiGeL - avatar
+ 2
#jojo thank you.
5th Jul 2017, 9:16 PM
RiGeL
RiGeL - avatar
+ 1
int a,b,c,d,e; cout<<enter ur number<<endl; cin>>a>>b>>c>>d>>e; if( a<b<c<d<e<) { cout<< "the minimum number is"<<a<<endl; that is my solution but i amn ot sure about it
5th Jul 2017, 7:31 PM
RiGeL
RiGeL - avatar
+ 1
No this won't work... You should try with 'if' inside 'if' and use a function. Ask if you want more informations
5th Jul 2017, 7:49 PM
Jojo
0
Are the numbers given in an array?
5th Jul 2017, 7:24 PM
zaqqwerty