0
Part(2) Having trouble at the output in C++ while loop with arrays
I have found a better solution for my last problem that doesn't include arrays but this new solution seems to have a problem on its own as well when i input big numbers like -40 0 5 -85 90. Please help point out my mistakes https://code.sololearn.com/cIQp7HQk7gDW/?ref=app https://www.sololearn.com/discuss/2729549/?ref=app
13 Answers
+ 2
Martin Taylor I can't show how much gratitude I have. I'll learn everything inside this code of yours. Reaally reaally thank youuđ€§đ€§đ
+ 2
// Hi, this is one propose
#include <iostream>
using namespace std;
int main()
{
int count = 0, small, n;
cout<<"This program only limited to 5 entries\nEnter first number: ";
cin>> small;
//syntax for while loop
while(true)
{
cin>>n;
if(n<small) small = n;
if(++count == 5) break;
}
//finding the smallest value
cout<<"\nThe smallest value is:"<<small<<endl;
return 0;
}
+ 1
Hello thank for the help. I have finally made a better code.
+ 1
Coder Kitten Thank you for pointing this out. If only i can just enter positive numbers and not negatives I wouldn't have to wrack my brain out. I guess this is too advance for me
+ 1
Thank you Ruben Enrique. This is my first time encountering while (true) it's very simple and easy to understand. Thank you for helping me!
0
Here is my answer! It works!
https://code.sololearn.com/cSZsvxBu79Qr/?ref=app
0
It's taking everything I have to answer this. So I'm always happy when I somehow improve.
0
It's still didn't worrrrkkkkk
0
My solution might help you:
https://code.sololearn.com/c53l8HDjABdO/?ref=app