Q:

Write a C program to Print ASCII value of entered character

0

C - Print ASCII value of entered character

In this C program, we will read a character values in a character variable and then store its ASCII value to an integer variable.

It’s really very easy to convert a character value to an integer variable, consider the given statement,

 integer_variable = (int)character_variable;

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Print ASCII value of entered character in C

/*C - Print ASCII value of entered character.*/
 
#include <stdio.h>
 
int main(){
    char ch;
    int asciiValue;
 
    printf("Enter any character: ");
    scanf("%c",&ch);
 
    asciiValue=(int)ch;
 
    printf("ASCII value of character: %c is: %d\n",ch,asciiValue);
 
}

Output

    Enter any character: x
    ASCII value of character: x is: 120

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now