C - Write program to output char ASCII code

Requirements

Read a character from console window.

Display its ASCII code.

Hint

The %d displays that value instead of a character value.

Demo

#include <stdio.h>

int main()/* w w  w  . j  a  v a 2  s. c om*/
{
    int c;

    printf("I'm waiting for a character: ");
    c = getchar();
    printf("I waited for the '%d' character.\n",c);
    return(0);
}

Result

Related Exercise