Algorithm
- Take an ASCII Value (Integer (0-127)) as input.
- Do cast the Integer to the corresponding character.
- Return the Result.
Code Examples
#1 CExample-C programing that displays the ASCII value of a single character variable:
Code -
C Programming
#include <stdio.h>
int main() {
char c;
printf("Enter a character: ");
scanf("%c", &c);
printf("The ASCII value of %c is %d", c, c);
return 0;
}
Copy The Code &
Try With Live Editor
Output
Enter a character: g
The ASCII value of g is 103
The ASCII value of g is 103
#2 Code Example C programing that displays the ASCII value of all the characters:
Code -
C Programming
#include <stdio.h>
int main() {
int i;
for(i = 33; i<= 126; i++) {
printf("The ASCII value of %c is %d\n", i, i);
}
return 0;
}
Copy The Code &
Try With Live Editor
Output
The ASCII value of !is 33
The ASCII value of " is 34
The ASCII value of # is 35
The ASCII value of $ is 36
The ASCII value of % is 37
The ASCII value of & is 38
The ASCII value of ' is 39
The ASCII value of ( is 40
The ASCII value of ) is 41
The ASCII value of * is 42
The ASCII value of + is 43
The ASCII value of , is 44
The ASCII value of - is 45
The ASCII value of .is 46
The ASCII value of / is 47
The ASCII value of 0 is 48
The ASCII value of 1 is 49
The ASCII value of 2 is 50
The ASCII value of 3 is 51
The ASCII value of 4 is 52
The ASCII value of 5 is 53
The ASCII value of 6 is 54
The ASCII value of 7 is 55
The ASCII value of 8 is 56
The ASCII value of 9 is 57
The ASCII value of : is 58
The ASCII value of ; is 59
The ASCII value of < is 60
The ASCII value of = is 61
The ASCII value of > is 62
The ASCII value of ?is 63
The ASCII value of @ is 64
The ASCII value of A is 65
The ASCII value of B is 66
The ASCII value of C is 67
The ASCII value of D is 68
The ASCII value of E is 69
The ASCII value of F is 70
The ASCII value of G is 71
The ASCII value of H is 72
The ASCII value of I is 73
The ASCII value of J is 74
The ASCII value of K is 75
The ASCII value of L is 76
The ASCII value of M is 77
The ASCII value of N is 78
The ASCII value of O is 79
The ASCII value of P is 80
The ASCII value of Q is 81
The ASCII value of R is 82
The ASCII value of S is 83
The ASCII value of T is 84
The ASCII value of U is 85
The ASCII value of V is 86
The ASCII value of W is 87
The ASCII value of X is 88
The ASCII value of Y is 89
The ASCII value of Z is 90
The ASCII value of [ is 91
The ASCII value of \ is 92
The ASCII value of ] is 93
The ASCII value of ^ is 94
The ASCII value of _ is 95
The ASCII value of ` is 96
The ASCII value of a is 97
The ASCII value of b is 98
The ASCII value of c is 99
The ASCII value of d is 100
The ASCII value of e is 101
The ASCII value of f is 102
The ASCII value of g is 103
The ASCII value of h is 104
The ASCII value of i is 105
The ASCII value of j is 106
The ASCII value of k is 107
The ASCII value of l is 108
The ASCII value of m is 109
The ASCII value of n is 110
The ASCII value of o is 111
The ASCII value of p is 112
The ASCII value of q is 113
The ASCII value of r is 114
The ASCII value of s is 115
The ASCII value of t is 116
The ASCII value of u is 117
The ASCII value of v is 118
The ASCII value of w is 119
The ASCII value of x is 120
The ASCII value of y is 121
The ASCII value of z is 122
The ASCII value of { is 123
The ASCII value of | is 124
The ASCII value of } is 125
The ASCII value of ~ is 126
The ASCII value of " is 34
The ASCII value of # is 35
The ASCII value of $ is 36
The ASCII value of % is 37
The ASCII value of & is 38
The ASCII value of ' is 39
The ASCII value of ( is 40
The ASCII value of ) is 41
The ASCII value of * is 42
The ASCII value of + is 43
The ASCII value of , is 44
The ASCII value of - is 45
The ASCII value of .is 46
The ASCII value of / is 47
The ASCII value of 0 is 48
The ASCII value of 1 is 49
The ASCII value of 2 is 50
The ASCII value of 3 is 51
The ASCII value of 4 is 52
The ASCII value of 5 is 53
The ASCII value of 6 is 54
The ASCII value of 7 is 55
The ASCII value of 8 is 56
The ASCII value of 9 is 57
The ASCII value of : is 58
The ASCII value of ; is 59
The ASCII value of < is 60
The ASCII value of = is 61
The ASCII value of > is 62
The ASCII value of ?is 63
The ASCII value of @ is 64
The ASCII value of A is 65
The ASCII value of B is 66
The ASCII value of C is 67
The ASCII value of D is 68
The ASCII value of E is 69
The ASCII value of F is 70
The ASCII value of G is 71
The ASCII value of H is 72
The ASCII value of I is 73
The ASCII value of J is 74
The ASCII value of K is 75
The ASCII value of L is 76
The ASCII value of M is 77
The ASCII value of N is 78
The ASCII value of O is 79
The ASCII value of P is 80
The ASCII value of Q is 81
The ASCII value of R is 82
The ASCII value of S is 83
The ASCII value of T is 84
The ASCII value of U is 85
The ASCII value of V is 86
The ASCII value of W is 87
The ASCII value of X is 88
The ASCII value of Y is 89
The ASCII value of Z is 90
The ASCII value of [ is 91
The ASCII value of \ is 92
The ASCII value of ] is 93
The ASCII value of ^ is 94
The ASCII value of _ is 95
The ASCII value of ` is 96
The ASCII value of a is 97
The ASCII value of b is 98
The ASCII value of c is 99
The ASCII value of d is 100
The ASCII value of e is 101
The ASCII value of f is 102
The ASCII value of g is 103
The ASCII value of h is 104
The ASCII value of i is 105
The ASCII value of j is 106
The ASCII value of k is 107
The ASCII value of l is 108
The ASCII value of m is 109
The ASCII value of n is 110
The ASCII value of o is 111
The ASCII value of p is 112
The ASCII value of q is 113
The ASCII value of r is 114
The ASCII value of s is 115
The ASCII value of t is 116
The ASCII value of u is 117
The ASCII value of v is 118
The ASCII value of w is 119
The ASCII value of x is 120
The ASCII value of y is 121
The ASCII value of z is 122
The ASCII value of { is 123
The ASCII value of | is 124
The ASCII value of } is 125
The ASCII value of ~ is 126
Demonstration
C Programing Example to Find ASCII Value of a Character-DevsEnv