0

Find the smallest number

//Please help me with the following question : How can the following code sequence be corrected to find the smallest number of 10 read from the keyboard? for (int i = 0; i < 10; i++) { int min; int number; std::cin >> number; if (number < min) { number = min; } }

17th Sep 2019, 3:25 PM
Bogdan Milko
Bogdan Milko - avatar
6 ответов
+ 1
sorry for the mistake! thank you very much for the explanation!
17th Sep 2019, 3:53 PM
Bogdan Milko
Bogdan Milko - avatar
+ 1
something so simple yet I got confused:)) thank you for replying! int main() { int min = INT_MAX; for(int i= 0;i<10;++i){ int num; cin>>num; if (num<=min) { min=num; } } cout<<min<<endl; return 0; }
17th Sep 2019, 9:21 PM
Bogdan Milko
Bogdan Milko - avatar