C - Working with character variables

Introduction

The char is a variable type in C.

When you work with characters, you use the char variable type to store them.

Demo

#include <stdio.h> 

int main() /*  w w w  .  j  a v  a  2  s. c  o  m*/
{ 
     char a,b,c,d; 

     a = 'W'; 
     b = a + 24; 
     c = b + 8; 
     d = '\n'; 
     printf("%c%c%c%c",a,b,c,d); 
     return(0); 
}

Result

The code declares four char variables.

These variables are assigned values.

All those %c placeholders are stuffed into the printf() statement.

Related Topic