C program to find Ascii value of character

 In this example, discuss how to find the ASCII value of the character in the c programming language. Following is the solution to this problem.

code:

#include <stdio.h>

int main() {  

    char ch;

    printf("Enter a character: ");

    scanf("%ch", &ch);  

    

    // %d display the integer value(ascii value) of a character

    // %c display  actual character

    printf("ASCII value of %c = %d", ch, ch);

    

    return 0;

}

Output:

Enter a character: a

ASCII value of a = 97


Here,take a character input from the user and display its integer value by using %d in printf.



Comments

Popular posts from this blog

Diferrence between flutter and react native

Flutter Widgets

Flutter layout