0

When I give input two smallest same numbers ....And how I make it shorter..

https://www.sololearn.com/post/812956/?ref=app

12th Dec 2020, 7:27 PM
Sid
Sid - avatar
2 Respuestas
0
Sid This is not a proper way to write code. You will never get output. Hint:- Store 1st value in a variable and compare this value with next value in loop. If next value is less than 1st value then next value will be minimum value.
12th Dec 2020, 7:37 PM
A͢J
A͢J - avatar
0
#include <iostream> using namespace std; int main() { double y=0.5; int age[5]; for (int i = 0; i < 5; ++i) { cin >> age[i]; } //your code goes here if (age[0]<=age[1] && age[0]<=age[2] && age[0]<=age[3] && age[0]<=age[4]){cout<<50-y*age[0]<<endl;} else {if (age[1]<=age[0] && age[1]<=age[2] && age[1]<=age[3] && age[1]<=age[4]){cout<<50-y*age[1]<<endl;} else {if (age[2]<=age[1] && age[2]<=age[0] && age[2]<=age[3] && age[2]<=age[4]){cout<<50-y*age[2]<<endl;} else {if (age[3]<=age[1] && age[3]<=age[2] && age[3]<=age[0] && age[3]<=age[4]){cout<<50-y*age[3]<<endl;} else {if (age[4]<=age[1] && age[4]<=age[2] && age[4]<=age[3] && age[4]<=age[0]){cout<<50-y*age[4]<<endl;}}}}} }
15th Dec 2020, 6:24 PM
Sid
Sid - avatar