0
Why no output?
#include <iostream> using namespace std; int main() { #define root = 40; for(int x = root, k = 0; x > 0, k > 0; x/=10, k++) { cout << k << endl; } return 0; }
4 Antworten
+ 4
#include <iostream>
#define root 40;
using namespace std;
int main()
{
int k;
for(int x = root;k = 0,x > 0, k > 0, x/=10, k++)
{
cout << k << endl;
}
return 0;
}
+ 2
I suggest you to read here https://en.cppreference.com/w/cpp/language/for
+ 1
k = 0 isn't condition
+ 1
The body of your for loop will be executed as long as “x > 0” and “k > 0” are true.
But initially k = 0, so the condition “k > 0” is false and the loop is exited.