Learn about C program to find ASCII value in a given Range in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
C program to find ASCII value in a given Range
In the below program i
and j
are the two variables which stores data range entered by user. Then for loop is used to iterate of the values and print the corresponding ASCII characters.
Source code:
#include<stdio.h>
int main()
{
int i, j;
int k;
printf("Enter Range (i and j value such that i<j): ");
scanf("%d %d",&i, &j);
for(k=i; k<=j; k++)
{
printf("ASCII value of %d is= %c\n", k, k);
}
return 0;
}
Output:
Enter Range (i and j value such that i<j): 97 105 ASCII value of 97 is= a ASCII value of 98 is= b ASCII value of 99 is= c ASCII value of 100 is= d ASCII value of 101 is= e ASCII value of 102 is= f ASCII value of 103 is= g ASCII value of 104 is= h ASCII value of 105 is= i
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
C program to display the ASCII value of a character
C Program to find Area of a triangle having three sides