Printing Ascii Codes as Characters Alphabets & Digits
Printing uppercase alphabets, lowercase alphabets, digits by printing them as characters typecasted from its integer form ascii values.
Learning Objectives
- Understanding ASCII code values of different Alphabets and Numbers
- Typecasting from numbers to characters.
Source Code
|
Run Output
Code Understanding
System.out.println(“– Uppercase characters with their ASCII codes –“);
for(int i=65;i<=90;++i) System.out.print(((char)i)+”=”+i+” “);
Prints character symbols of ASCII codes from 65 to 90 which are A – Z
System.out.println(“n– Lowercase characters with their ASCII codes –“);
for(int i=97;i<=122;++i) System.out.print(((char)i)+”=”+i+” “);
Prints character symbols of ASCII codes from 97 to 122 which are a – z
System.out.println(“n– Digits 0 to 9 with their ASCII codes –“);
for(int i=48;i<=57;++i) System.out.print(((char)i)+”=”+i+” “);
Prints character symbols of ASCII codes from 48 to 57 which are 0 – 9
Notes
- ASCII codes from 32 to 126 are displayable characters.
- The lowercase ascii equivalent can always be obtained by adding 32 to uppercase alphabets and vice-versa is also true.
Suggested Filename(s): CharAndAscii.java
sunmitra| Created: 16-Feb-2018 | Updated: 21-Mar-2018|