Solution for Exercise 7-2

ex0702

#include <stdio.h>

int main()
{
    int c;

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

Notes

* To explore the ASCII code/character concept further, change Line 9 in the code (the second printf() statement) so that both the code value and character for variable c are displayed. Something like:

Click here to view my solution to the above problem.