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.

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

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

Okay