How to print characters in the C language?

In the C language, the printf function can be used to print characters. Here are some common ways to print characters:

  1. Print a single character.
char ch = 'A';
printf("%c\n", ch);
  1. Print an array of characters (string):
char str[] = "Hello";
printf("%s\n", str);
  1. Print the corresponding character of the ASCII code:
int ascii = 65;
printf("%c\n", ascii);

In the above code, %c is a placeholder for formatting a character, used for printing a single character. %s is used for printing strings until the string termination character ‘\0’ is encountered. %d is used for printing integers.

bannerAds