Numeric nature of char variables - C Data Type

C examples for Data Type:char

Description

Numeric nature of char variables

Demo Code

#include <stdio.h>

int main( void )
{
    char c1 = 'a';
    char c2 = 90;
    /* Print variable c1 as a character, then as a number */

    printf("\nAs a character, variable c1 is %c", c1);
    printf("\nAs a number, variable c1 is %d", c1);

    printf("\nAs a character, variable c2 is %c", c2);
    printf("\nAs a number, variable c2 is %d\n", c2);

    return 0;//from w  ww . j  a  va2  s . com
}

Result


Related Tutorials