DEV Community

Cover image for Predict the Output
Swastik Baranwal
Swastik Baranwal

Posted on

4 2

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.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay