write c program to Print the ASCII Value of the Character

Ram Pothuraju

 #include <stdio.h>


int main()

{

    char c;

    

    printf("Enter a character: ");

    scanf("%c", &c);

    

    printf("The ASCII value of %c is %d.\n", c, c);

    

    return 0;

}


In this program, we first declare a variable c of type char.


We then prompt the user to enter a character using the printf and scanf functions.


Next, we use the %c format specifier to print the character entered by the user, and the %d format specifier to print its corresponding ASCII value.


When the program is run, it will output the ASCII value of the character entered by the user.


Post a Comment

0Comments

Post a Comment (0)