Displaying Character Data Types with printf() - C Data Type

C examples for Data Type:Introduction

Introduction

Characters are also easy to display using the %c conversion specifier.

Demo Code

#include <stdio.h>

int main()//from w ww .j av a  2  s.c o m
{
    printf("%c", 'M'); 
    return 0;
}

Result

You can output the contents of a character variable data type using the %c conversion specifier and a printf() function.

Demo Code

#include <stdio.h>

int main()/* ww w  .  ja v a2s  .  c o  m*/
{
    char firstInitial; 
    
    firstInitial = 'S'; 
    
    printf("The value of firstInitial is %c", firstInitial); 
    return 0;
}

Result


Related Tutorials