0

My code isn't working can somebody help me

#include <iostream> using namespace std; int main() { int num,ln=1,small; while(ln<=5) { cout<<"\nEnter a Number: "; cin>>num; ++ln; if(num<=small) {small=num;} else {small=small;} } cout<<"\nThe Smallest Number is: "<<small; return 0; }

22nd Oct 2020, 1:17 AM
Christian Vilaga
Christian Vilaga - avatar
5 Réponses
+ 4
I said any number bigger then your inputs. Like small=100;
22nd Oct 2020, 1:29 AM
Azhagesanヾ(✿)
Azhagesanヾ(✿) - avatar
+ 2
Your code working just put initial value to small variable. (Any big number) . You're comparing unknown value to a variable. So that it's not working. Just give value to small variable
22nd Oct 2020, 1:27 AM
Azhagesanヾ(✿)
Azhagesanヾ(✿) - avatar
0
I tried to put 0 in small variable then the smallest is 0
22nd Oct 2020, 1:29 AM
Christian Vilaga
Christian Vilaga - avatar
0
You didn't give a value to the variable "small"
22nd Oct 2020, 11:52 PM
Marilena Bivolaru
Marilena Bivolaru - avatar