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()/*from w w  w.  ja v a 2  s .  com*/
{
    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