QP School

Full Version: Printing a character in C
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Example:

char letter = 'B';
printf("The letter is: %c\n", letter);

Explanation:

In this example, we declare a variable letter of type char and assign it the character 'B'.
We use the %c format specifier in the printf() function to print the value of the char variable.
When the printf() function is executed, it will replace %c with the value of letter and print "The letter is: B".