In this tutorial you will learn about the C Program to find the ASCII Value of Total Characters in a String and its application with practical example.
C Program to find the ASCII Value of Total Characters in a String
In this tutorial, we will learn to create a C program that will find the ASCII Value of Total Characters in a String in C programming.
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. ASCII is a subset of Unicode and is made up of 128 symbols in the character set.
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 ASCII Value of Total Characters in a String
In today’s program, we will first take the input string from the user for the program. Then we will find the values for all characters using a for loop. Then we will Print the ASCII values of each character in the string.
With the help of the below program, we can Check the ASCII value of total Characters in a string.
* C Program to find the ASCII Value of Total Characters in a String
//Decalring the required variable for the program
//Taking the input string for the program to find ascii value
printf("\n Please Enter any String : ");
Passing that string to the for loop
for finging the ascii value of each characters
for( int i = 0; str[i] != ‘\0’; i++)
printf(" The ASCII Value of Character %c = %d \n", str[i], str[i]);
In the above program, we have first initialized the required variable.
- str = it will hold the string value for the input.
Input string from the user.
Finding the character ASCII values.
Printing output for the program.