Skip to content
Related Articles

Related Articles

C Program To Print ASCII Value of a Character

View Discussion
Improve Article
Save Article
  • Last Updated : 19 Jul, 2022

Given a character, we need to print its ASCII value in C.

C Program To Print ASCII Value of a Character Examples:

Input: a 
Output: 97

Input: D
Output: 68

C code: We use format specifier here to give numeric value of character. Here %d is used to convert character to its ASCII value.

C




// C program to print
// ASCII Value of Character
#include <stdio.h>
 
// Driver code
int main()
{
    char c = 'k';
 
    // %d displays the integer value of
    // a character
    // %c displays the actual character
    printf("The ASCII value of %c is %d",
            c, c);
    return 0;
}

Output:

The ASCII value of k is 107

Time complexity: O(1) since performing constant operations

Auxiliary Space: O(1)

Please refer complete article on Program to print ASCII Value of a character for more details!

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!