Write a program to print the value EOF.

Source:

#include "stdio.h"

int main(int argc, char *argv[])
{
  int running = 1;

  int character;

  printf("Type a letter to see it's value.\nSubmit 'q' to quit.\n");

  while(running)
  {
    character = getchar();

    if(character != '\n' && character != EOF)
    {
      printf("%c = %i\n", character, character);
    }
    else if(character == '\n')
    {
      printf("[enter] = %i\n", character);
    }
    else if(character == EOF)
    {
      printf("[EOF] = %i\n", character);
    }

    if(character == 'q')
    {
      running = 0;
    }
  }

  return 0;
}

Output:

Type a letter to see it's value.
Submit 'q' to quit.
[EOF] = -1
q = 113