BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

C Program to Find ASCII value of a Character

Last Updated: September 24, 2017 by Chaitanya Singh | Filed Under: C Programs

ASCII value represents the English characters as numbers, each letter is assigned a number from 0 to 127. For example, the ASCII value for uppercase Q is 81.

Example 1: Program to display ASCII value of a character entered by user

This program takes the character entered by user and displays the ASCII value of it.

#include <stdio.h>
int main()
{
    char ch;
    printf("Enter any character:");

    /* Reads the entered character and stores it
     * into the char variable ch
     */
    scanf("%c", &ch);

    /* Using the format specifiers we can get the ASCII code
     * of a character. When we use %d format specifier for a
     * char variable then it displays the ASCII value of a char
     */
    printf("ASCII value of character %c is: %d", ch, ch);
    return 0;
}

Output:

Enter any character:Q
ASCII value of character Q is: 81

Check out the related C Programs:

  1. C Program to display Fibonacci Series
  2. C Program to check if number is even or odd
  3. C Program to calculate and print the value of nPr
  4. C Program to convert uppercase string to lowercase

Top Related Articles:

  1. C Program to concatenate two strings without using strcat
  2. C program to Reverse a String using recursion
  3. C Program to check Leap Year
  4. C Program to Search Substring in a given String
  5. C Program to print number of days in a month

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap