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; }

15th Nov 2018, 2:04 PM
Igor The Golden Fish
Igor The Golden Fish - avatar
4 Respuestas
+ 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; }
15th Nov 2018, 2:39 PM
Izaak GOLDSTEIN
Izaak GOLDSTEIN - avatar
15th Nov 2018, 2:23 PM
KrOW
KrOW - avatar
+ 1
k = 0 isn't condition
15th Nov 2018, 2:41 PM
Igor The Golden Fish
Igor The Golden Fish - avatar
+ 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.
15th Nov 2018, 2:46 PM
Diego
Diego - avatar