DEV Community

loading...
Cover image for Predict the Output

Predict the Output

delta456 profile image Swastik Baranwal ・1 min read

Predict the output of the following code and tell me why this works:

#include <stdio.h>
int main()
{
    int x = 10;
    while (x --> 0) 
    {
        printf("%d ", x);
    }
   return 0;
}

The one who answers well will get a follow back!

Discussion (4)

pic
Editor guide
Collapse
delta456 profile image
Swastik Baranwal Author

Great! Can you also tell why --> works?

delta456 profile image
Swastik Baranwal Author

Yeah correct but --> works because the lexer ignores whitespace and x-- is parsed.