C program to print all ASCII characters and ASCII values/numbers
Problem Description:
Write a Program to print all ASCII characters and their ASCII numbers
Examples:
Our task to print all ASCII characters with their ASCII number
Here are few ASCII Characters and their ASCII numbers.
- For ASCII character Space the ASCII value is 32
- character ‘A’ (Capital A) the ASCII value is 65
- For ‘a’ (small a ) the ASCII value is 97
- For 0 (zero) the ASCII value is 48
What is ASCII Number:
ASCII stands for American Standard Code for Information Interchange. It is a character encoding format.
The characters are not directly stored into the memory, We use the encoding to store in efficient way.
ASCII one of the encoding formats. There are other encoding standards such as Unicode (UTF-8, UTF-16, UTF-32) and etc.
ASCII standards contains 255 characters. We are going try to print all these 255 characters ASCII Characters with their Numbers.
But only 127 ASCII characters are printable characters. To be exact the printable ASCII Characters from number 32 which is space to number 126 which is ESC. So our output might gives undefined values after 127 characters.
Program Logic:
As we know we have 255 ASCII characters. We are going to for loop iterate 255 times.
The basic idea is to pass the integer value to printf function and use the character format specifier ( %c ). So the printf function will cast the integer to ASCII character. and prints the output to the console.
We are going to repeat the above process for all ASCII number
from 0 to 255. At each iteration will make use of integer to character typecasting to print ASCII characters.
Print all ASCII characters and ASCII numbers Program:
1 2 3 4 5 6 7 8 9 10 |
include<stdio.h> int main() { int i; for(i=0;i<=255;i++) { printf("ASCII value :%d \t and Ascii character :%c \n ",i,i); } return 0; } |
Print ASCII values Output:
All ASCII Characters with Respective ASCII Numbers. Please note few characters are not printable.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
$ ./a.out ASCII value :0 and Ascii character : ASCII value :1 and Ascii character : ASCII value :2 and Ascii character : ASCII value :3 and Ascii character : ASCII value :4 and Ascii character : ASCII value :5 and Ascii character : ASCII value :6 and Ascii character : ASCII value :7 and Ascii character : ASCII value :8 and Ascii character ASCII value :9 and Ascii character : ASCII value :10 and Ascii character : ASCII value :11 and Ascii character : ASCII value :12 and Ascii character : ASCII value :13 and Ascii character : ASCII value :14 and Ascii character : ASCII value :15 and Ascii character : ASCII value :16 and Ascii character : ASCII value :17 and Ascii character : ASCII value :18 and Ascii character : ASCII value :19 and Ascii character : ASCII value :20 and Ascii character : ASCII value :21 and Ascii character : ASCII value :22 and Ascii character : ASCII value :23 and Ascii character : ASCII value :24 and Ascii character : ASCII value :25 and Ascii character : ASCII value :26 and Ascii character : ASCII value :27 and Ascii character : SCII value :28 and Ascii character : ASCII value :29 and Ascii character : ASCII value :30 and Ascii character : ASCII value :31 and Ascii character : ASCII value :32 and Ascii character : ASCII value :33 and Ascii character :! ASCII value :34 and Ascii character :" ASCII value :35 and Ascii character :# ASCII value :36 and Ascii character :$ ASCII value :37 and Ascii character :% ASCII value :38 and Ascii character :& ASCII value :39 and Ascii character :' ASCII value :40 and Ascii character :( ASCII value :41 and Ascii character :) ASCII value :42 and Ascii character :* ASCII value :43 and Ascii character :+ ASCII value :44 and Ascii character :, ASCII value :45 and Ascii character :- ASCII value :46 and Ascii character :. ASCII value :47 and Ascii character :/ ASCII value :48 and Ascii character :0 ASCII value :49 and Ascii character :1 ASCII value :50 and Ascii character :2 ASCII value :51 and Ascii character :3 ASCII value :52 and Ascii character :4 ASCII value :53 and Ascii character :5 ASCII value :54 and Ascii character :6 ASCII value :55 and Ascii character :7 ASCII value :56 and Ascii character :8 ASCII value :57 and Ascii character :9 ASCII value :58 and Ascii character :: ASCII value :59 and Ascii character :; ASCII value :60 and Ascii character :< ASCII value :61 and Ascii character := ASCII value :62 and Ascii character :> ASCII value :63 and Ascii character :? ASCII value :64 and Ascii character :@ ASCII value :65 and Ascii character :A ASCII value :66 and Ascii character :B ASCII value :67 and Ascii character :C ASCII value :68 and Ascii character :D ASCII value :69 and Ascii character :E ASCII value :70 and Ascii character :F ASCII value :71 and Ascii character :G ASCII value :72 and Ascii character :H ASCII value :73 and Ascii character :I ASCII value :74 and Ascii character :J ASCII value :75 and Ascii character :K ASCII value :76 and Ascii character :L ASCII value :77 and Ascii character :M ASCII value :78 and Ascii character :N ASCII value :79 and Ascii character :O ASCII value :80 and Ascii character :P ASCII value :81 and Ascii character :Q ASCII value :82 and Ascii character :R ASCII value :83 and Ascii character :S ASCII value :84 and Ascii character :T ASCII value :85 and Ascii character :U ASCII value :86 and Ascii character :V ASCII value :87 and Ascii character :W ASCII value :88 and Ascii character :X ASCII value :89 and Ascii character :Y ASCII value :90 and Ascii character :Z ASCII value :91 and Ascii character :[ ASCII value :92 and Ascii character :\ ASCII value :93 and Ascii character :] ASCII value :94 and Ascii character :^ ASCII value :95 and Ascii character :_ ASCII value :96 and Ascii character :` ASCII value :97 and Ascii character :a ASCII value :98 and Ascii character :b ASCII value :99 and Ascii character :c ASCII value :100 and Ascii character :d ASCII value :101 and Ascii character :e ASCII value :102 and Ascii character :f ASCII value :103 and Ascii character :g ASCII value :104 and Ascii character :h ASCII value :105 and Ascii character :i ASCII value :106 and Ascii character :j ASCII value :107 and Ascii character :k ASCII value :108 and Ascii character :l ASCII value :109 and Ascii character :m ASCII value :110 and Ascii character :n ASCII value :111 and Ascii character :o ASCII value :112 and Ascii character :p ASCII value :113 and Ascii character :q ASCII value :114 and Ascii character :r ASCII value :115 and Ascii character :s ASCII value :116 and Ascii character :t ASCII value :117 and Ascii character :u ASCII value :118 and Ascii character :v ASCII value :119 and Ascii character :w ASCII value :120 and Ascii character :x ASCII value :121 and Ascii character :y ASCII value :122 and Ascii character :z ASCII value :123 and Ascii character :{ ASCII value :124 and Ascii character :| ASCII value :125 and Ascii character :} ASCII value :126 and Ascii character :~ ASCII value :127 and Ascii character : ASCII value :128 and Ascii character :� ASCII value :129 and Ascii character :� ASCII value :130 and Ascii character :� ASCII value :131 and Ascii character :� ASCII value :132 and Ascii character :� ASCII value :133 and Ascii character :� ASCII value :134 and Ascii character :� ASCII value :135 and Ascii character :� ASCII value :136 and Ascii character :� ASCII value :137 and Ascii character :� ASCII value :138 and Ascii character :� ASCII value :139 and Ascii character :� ASCII value :140 and Ascii character :� ASCII value :141 and Ascii character :� ASCII value :142 and Ascii character :� ASCII value :143 and Ascii character :� ASCII value :144 and Ascii character :� ASCII value :145 and Ascii character :� ASCII value :146 and Ascii character :� ASCII value :147 and Ascii character :� ASCII value :148 and Ascii character :� ASCII value :149 and Ascii character :� ASCII value :150 and Ascii character :� ASCII value :151 and Ascii character :� ASCII value :152 and Ascii character :� ASCII value :153 and Ascii character :� ASCII value :154 and Ascii character :� ASCII value :155 and Ascii character :� ASCII value :156 and Ascii character :� ASCII value :157 and Ascii character :� ASCII value :158 and Ascii character :� ASCII value :159 and Ascii character :� ASCII value :160 and Ascii character :� ASCII value :161 and Ascii character :� ASCII value :162 and Ascii character :� ASCII value :163 and Ascii character :� ASCII value :164 and Ascii character :� ASCII value :165 and Ascii character :� ASCII value :166 and Ascii character :� ASCII value :167 and Ascii character :� ASCII value :168 and Ascii character :� ASCII value :169 and Ascii character :� ASCII value :170 and Ascii character :� ASCII value :171 and Ascii character :� ASCII value :172 and Ascii character :� ASCII value :173 and Ascii character :� ASCII value :174 and Ascii character :� ASCII value :175 and Ascii character :� ASCII value :176 and Ascii character :� ASCII value :177 and Ascii character :� ASCII value :178 and Ascii character :� ASCII value :179 and Ascii character :� ASCII value :180 and Ascii character :� ASCII value :181 and Ascii character :� ASCII value :182 and Ascii character :� ASCII value :183 and Ascii character :� ASCII value :184 and Ascii character :� ASCII value :185 and Ascii character :� ASCII value :186 and Ascii character :� ASCII value :187 and Ascii character :� ASCII value :188 and Ascii character :� ASCII value :189 and Ascii character :� ASCII value :190 and Ascii character :� ASCII value :191 and Ascii character :� ASCII value :192 and Ascii character :� ASCII value :193 and Ascii character :� ASCII value :194 and Ascii character :� ASCII value :195 and Ascii character :� ASCII value :196 and Ascii character :� ASCII value :197 and Ascii character :� ASCII value :198 and Ascii character :� ASCII value :199 and Ascii character :� ASCII value :200 and Ascii character :� ASCII value :201 and Ascii character :� ASCII value :202 and Ascii character :� ASCII value :203 and Ascii character :� ASCII value :204 and Ascii character :� ASCII value :205 and Ascii character :� ASCII value :206 and Ascii character :� ASCII value :207 and Ascii character :� ASCII value :208 and Ascii character :� ASCII value :209 and Ascii character :� ASCII value :210 and Ascii character :� ASCII value :211 and Ascii character :� ASCII value :212 and Ascii character :� ASCII value :213 and Ascii character :� ASCII value :214 and Ascii character :� ASCII value :215 and Ascii character :� ASCII value :216 and Ascii character :� ASCII value :217 and Ascii character :� ASCII value :218 and Ascii character :� ASCII value :219 and Ascii character :� ASCII value :220 and Ascii character :� ASCII value :221 and Ascii character :� ASCII value :222 and Ascii character :� ASCII value :223 and Ascii character :� ASCII value :224 and Ascii character :� ASCII value :225 and Ascii character :� ASCII value :226 and Ascii character :� ASCII value :227 and Ascii character :� ASCII value :228 and Ascii character :� ASCII value :229 and Ascii character :� ASCII value :230 and Ascii character :� ASCII value :231 and Ascii character :� ASCII value :232 and Ascii character :� ASCII value :233 and Ascii character :� ASCII value :234 and Ascii character :� ASCII value :235 and Ascii character :� ASCII value :236 and Ascii character :� ASCII value :237 and Ascii character :� ASCII value :238 and Ascii character :� ASCII value :239 and Ascii character :� ASCII value :240 and Ascii character :� ASCII value :241 and Ascii character :� ASCII value :242 and Ascii character :� ASCII value :243 and Ascii character :� ASCII value :244 and Ascii character :� ASCII value :245 and Ascii character :� ASCII value :246 and Ascii character :� ASCII value :247 and Ascii character :� ASCII value :248 and Ascii character :� ASCII value :249 and Ascii character :� ASCII value :250 and Ascii character :� ASCII value :251 and Ascii character :� ASCII value :252 and Ascii character :� ASCII value :253 and Ascii character :� ASCII value :254 and Ascii character :� ASCII value :255 and Ascii character :� $ |
Related C Programs:
- C Program to find sum of digits of a Number | Sum of Digits program in C – SillyCodes
- Armstrong Number Program in C Language – SillyCodes
15 Responses
[…] C program to print all ASCII characters and ASCII values/numbers – SillyCodes […]
[…] C program to print all ASCII characters and ASCII values/numbers – SillyCodes […]
[…] C program to print all ASCII characters and ASCII values/numbers – SillyCodes […]
[…] C program to print all ASCII characters and ASCII values/numbers – SillyCodes […]
[…] 📢 We have discussed all characters and their ASCII values in this post. C program to print all ASCII characters and ASCII values/numbers – SillyCodes […]
[…] C program to print all ASCII characters and ASCII values/numbers – SillyCodes […]
[…] C program to print all ASCII characters and ASCII values/numbers – SillyCodes […]
[…] C program to print all ASCII characters and ASCII values/numbers – SillyCodes […]
[…] C program to print all ASCII characters and ASCII values/numbers – SillyCodes […]
[…] C Program to Print All ASCII Charcters and ASCII Values […]
[…] C Program to Print All ASCII Charcters and ASCII Values […]
[…] NULL Character( ) is a special character and its ASCII Value is equal to […]
[…] Related: List of ASCII characters with it’s values […]
[…] Here is the List of ASCII Characters with ASCII Values […]
[…] List of ASCII Characters with the ASCII Values in C […]