DEV Community

Cover image for Predict the Output
Swastik Baranwal
Swastik Baranwal

Posted on

Predict the Output

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;
}
Enter fullscreen mode Exit fullscreen mode

The one who answers well will get a follow back!

Top comments (2)

Collapse
 
delta456 profile image
Swastik Baranwal

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

 
delta456 profile image
Swastik Baranwal

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