C program to print ASCII value of all characters

Program to print ASCII values

C program to print ASCII value of all characters

Before moving to the program first of all we need to understand the ASCII values.

ASCII stands for American Standard Code for Information Interchange. It is a set of integer values that represent different printable and non-printable characters.
In C programming characters are stored as an integer value (ASCII value between 0 and 127) rather than that character itself. That value is known as its ASCII value.

#include <stdio.h>
void main() {  
    char c;
printf("\n\t\t\t...Welcome To EduNews.Tech... ");
    printf("\n\nEnter a character: ");
    scanf("%c", &c);  
    // %d displays the integer value of a character
    // %c displays the actual character
    printf("ASCII value of %c = %d", c, c);
printf("\n\n\n\n\t\t\tThankyou for Joining Us !");
    printf("\n\t\t\t!Regards EduNews !");

Program Output:

ASCII value

In this program, the user is asked to enter a character. The character is stored in variable c.

-When the %d format string is used, 65 (the ASCII value of A) is displayed.
-When the %c format string is used, ‘A’ itself is displayed.

I hope this post helps you to understand the ASCII values and its implementation in C programming language.

Keep coding 🙂

Leave a Reply

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