Menu

Add Topic

C Programming

waiting answer January 05, 2021

Write a C Program to Find ASCII Value of a Character

Answers
January 05, 2021

In C programming, a character holds the value of C rather than that of character.
Example

  • The ASCII value of a is 97
  • The ASCII value of A is 65
       

If you input A to a character variable, 65 is stored into a character variable. You should have basic knowledge in C input/output, C variables, etc.

    #include <stdio.h>
    int main() {  
        char ch;
        printf("Enter a character: ");
        scanf("%c", &ch);  
        printf("ASCII value of %c is %d", ch, ch);
        return 0;
    }

OUTPUT

         Enter a character: B
         ASCII value of B is 66

In this program, the user inputs a character. The input character is stored in ch. %d format is used to convert the input character to ASCII value. Suppose the input is v, the ASCII value of the input character is 118.

0 0
January 05, 2021

ASCII stands for American Standard Code for information interchange. ASCII is a character encoding scheme used for electronic communication. Each character is represented by some ASCII code.

In C programming, the ASCII value represents the character variable in numbers. The number range from 0 to 127. For example, the ASCII value of A is 65.

0 0

Please Login to Post the answer

Leave an Answer