Hi everyone
This is my question HELP please...
Write an algorithm to fill 6 positions in a vector, integer, values between 20 and -20, and the print on the screen. Then will be shown how many numbers read are positive values.
The output must be like this:
Insert an value between 20 and -20: -10
Insert an value between 20 and -20: 8
Insert an value between 20 and -20: 9
Insert an value between 20 and -20: 10
Insert an value between 20 and -20: 5
Insert an value between 20 and -20: 6
Inserted numbers
Inserted Value: -10
Inserted Value: 8
Inserted Value: 9
Inserted Value: 10
Inserted Value: 5
Inserted Value: 6
-> There are 5 positive values

VulpesRank #55 · 29.2K reputationPosted Feb 14, 2014, 2:13 AM EST
Guest User28 reputationPosted Feb 14, 2014, 2:32 AM EST
but can you explain this part thanks
VulpesRank #55 · 29.2K reputationPosted Feb 14, 2014, 3:01 AM EST
If it can, then the method returns true and the value is assigned to the 'out' parameter.
If it can't, then the method returns false and 0 is assigned to the 'out' parameter.
So, if this method return returns false (because the user enters 'abc' say) or if it returns an int which is less than -20 or more than 20, we print an error message and ask the user to re-input the number.
It's just an easy way to validate input.
Guest User28 reputationPosted Feb 14, 2014, 3:05 AM EST