ASCII Value

ASCII (American Standard Code for Information Interchange) is the character encoding standard of electronic communication. ASCII codes represent text within computers, telecommunications equipment, and other devices. – Wikipedia

Logic

To find the ASCII value of a character we have to cast into an integer data type. If the character is cast into an integer data type it automatically returns its ASCII value.

Casting is a way to convert a variable from one data type to another data type.

Program

#include <stdio.h>

int main() {

    int a;
    char ch;

    printf("Enter any character : ");

    scanf("%c", &ch);

    a = ch;

    printf("\nASCII value of %c is %d", ch, a);
    
    return 0;
}

Output

Enter any character : S
ASCII value of S is 113