In this tutorial you will learn about the C program to find ASCII Values of all Characters and its application with practical example.
C Program to find the ASCII Value of All Characters
In this tutorial, we will learn to create a C program that will find the ASCII Value of All Characters in C programming.
Prerequisites
Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- For loop in C programming.
What is ASCII value?
The ASCII stands for American Standard Code for Information Interchange. The ASCII is used for character encoding for text data in computers and other devices. There is a total of 256 ASCII values. ASCII is a subset of Unicode and is made up of 128 symbols in the character set.
Algorithm:-
1 2 3 4 5 6 7 8 9 10 11 |
1. Declaring the variables for the program. 2. Taking the input string from the user. 3. Passing those variables to for loop. 4. Finding the ASCII value of each character in the string. 5. Printing the values for the characters. 6. End Program. |
Program to print ASCII Value of All Characters.
In today’s program, we will first declare a variable in integer format having the value “i=0”. Then we will use a for loop printing all the values. There are 256 values in ASCII, and 128 of them are unique characters.
With the help of the below program, we can print the ASCII value of all characters.
Program Code:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
/** * C Program to find the ASCII Value of All Characters */ #include <stdio.h> int main() { //declaring the required value for the [program]. int i; // i = it will hold the integer value for the loop controlling. /* Print ASCII values from 0 to 255 using the for loop */ for(i=0; i<=255; i++) { //printing the ASCII values of all the characters. printf("ASCII value of character %c = %d\n", i, i); } return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- i = it will hold the integer value for the loop.
For loop for values.
Finding the character ASCII values and printing the values.
Main function code of the program.