Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

C Character input

Program to take character as input in C Programming.

#include <stdio.h>

int main() {
    char input;

    printf("Enter a character: ");
    scanf("%c", &input);

    printf("You entered: %c\n", input);

    return 0;


  1. The #include <stdio.h> line includes the standard input/output library, which provides functions like printf() and scanf().
  2. The main() function is the entry point of the program.
  3. The variable input is declared as a character. It will store the user’s input.
  4. The printf() function displays the message “Enter a character: ” to prompt the user for input.
  5. The scanf() function with the %c format specifier is used to read a character from the user’s input. The & operator is used to pass the memory address of the input variable so that the value can be stored there.
  6. The printf() function displays the message “You entered: ” followed by the value stored in the input variable, using the %c format specifier.
  7. The return 0; statement indicates the successful completion of the main() function, and the program terminates.
C Output
Enter a character: E
You entered: E