C examples for Language Basics:Console
Using characters as menu choices.
#include <stdio.h> int main()/*from www. jav a2 s. c om*/ { char cResponse = '\0'; printf("\na\tTurn the AC on\n"); printf("b\tTurn the AC off\n"); printf("\nEnter your selection: "); scanf("%c", &cResponse); if (cResponse == 'a'){ printf("\nAC is now on\n"); } if (cResponse == 'b') { printf("\nAC is now off\n"); } }