When does a C program print out an output of -1?

I was taking a practice programming quiz, and I’m not sure why this program prints out -1:

#include <stdio.h>

int main()
{
    int x = 1;

    if (x-- && x-- && x--)
    {
        printf("%d\n", x);
    } else
    {
        printf("%d\n", x);
    }
    return 0;
}


Download when.does.a.c.program.print.out.an.output.of.1.zip
Direct Link


Download


Download when.does.a.c.program.print.out.an.output.of.1.zip
Mediafire


Download


Download when.does.a.c.program.print.out.an.output.of.1.zip
Extabit


Download

Both comments and pings are currently closed.

Comments are closed.