Exercise 1-6

Verify that the expression getchar() != EOF is 0 or 1.

The values zero and one are integer values, so we use the %d format specifier and pass getchar() != EOF as an argument to printf.

    #include <stdio.h>
    
    main()
    {
        printf("%d\n", getchar() != EOF);
    }

After running the program, you will find that when Ctrl-D (or Ctrl-Z + Enter on Windows) is entered, the value of the expression is one; otherwise, it is zero. Perhaps this tells us something along the lines of true statements being equal to the value one and false statements being equal to zero. But let us not get too ahead of ourselves!