+ 1
What is wrong with this code?
If user inputs 5 then the program should print : 5 4 3 2 1 0 I tried to do this using while loop in c++ but the code is not printing anything, this is the code: #include <iostream> using namespace std; int main() { int n; cin>>n; while(n<=0){ cout<<n<<"\n"; n--; } } Please Help.
3 odpowiedzi
+ 5
Hi! Just change <= for >=
If you input 5, 5 is not less or equal to 0, so you while will never be executed
+ 3
Oh yes, that happens when you are handling a lot of associative arrays in php, one usually gets confused 🙄
Anyways a compile run error fix it, so calm down you "human compiler" 🤗
+ 2
Incredible
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
while(n>=0){
cout<<n<<"\n";
n--;
}
return 0;
}