Output the numeric value of a character - C Data Type

C examples for Data Type:char

Introduction

This statement will output the value in ch as a character and as a numeric value.

Demo Code

#include <stdio.h> 
  
int main(void) 
{
    char ch = 0;//from  www  . j av a 2  s  . c  om
    scanf("%c", &ch);                           // Read one character
    
    printf("The character is %c\n", ch);
    printf("The character is %c and the code value is %d\n", ch, ch);

    return 0; 
}

Result


Related Tutorials