ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

C - Print ASCII of All Upper and Lower Case Characters in Decimal and Hexadecimal using C Program.


IncludeHelp 04 August 2016

In this code snippet, we will learn how to print ASCII values of all Upper and Lower case characters in decimal and hexadecimal using c program.

It is very easy to get ASCII value of any character in c language, you have to just print the character value in %d (for decimal) and %x (for hexadecimal).

In this program we used two loops, first loop is running from character 'A' to 'Z' and second loop is running from character ‘a’ to ‘z’. And program is printing the values in %d and %x format.

We used %03d - to pad value with 0 in 3 digits, and %02X – to pad value with 0 in 2 digits, capital X is used to display capital characters in hexadecimal code.

C Code Snippet - Print ASCII Values of All Upper and Lower Case Characters in Decimal and Hexadecimal

/*C - Print ASCII of All Upper and Lower Case Characters 
in Decimal and Hexadecimal using C Program.*/

#include <stdio.h>

int main(){
	char loop;
	
	printf("\nUpper Case Characters:\n");
	for(loop='A';loop<='Z';loop++){
		printf("[%c]- %03d - %02X ",loop,loop,loop);
	}
	
	printf("\nLower Case Characters:\n");
	for(loop='a';loop<='z';loop++){
		printf("[%c]- %03d - %02X ",loop,loop,loop);
	}	
	
	printf("\n");
	return 0;
}
    Upper Case Characters:
    [A]- 065 - 41 [B]- 066 - 42 [C]- 067 - 43 [D]- 068 - 44 
    [E]- 069 - 45 [F]- 070 - 46 [G]- 071 - 47 [H]- 072 - 48 
    [I]- 073 - 49 [J]- 074 - 4A [K]- 075 - 4B [L]- 076 - 4C 
    [M]- 077 - 4D [N]- 078 - 4E [O]- 079 - 4F [P]- 080 - 50 
    [Q]- 081 - 51 [R]- 082 - 52 [S]- 083 - 53 [T]- 084 - 54 
    [U]- 085 - 55 [V]- 086 - 56 [W]- 087 - 57 [X]- 088 - 58 
    [Y]- 089 - 59 [Z]- 090 - 5A
    Lower Case Characters:
    [a]- 097 - 61 [b]- 098 - 62 [c]- 099 - 63 [d]- 100 - 64 
    [e]- 101 - 65 [f]- 102 - 66 [g]- 103 - 67 [h]- 104 - 68 
    [i]- 105 - 69 [j]- 106 - 6A [k]- 107 - 6B [l]- 108 - 6C 
    [m]- 109 - 6D [n]- 110 - 6E [o]- 111 - 6F [p]- 112 - 70 
    [q]- 113 - 71 [r]- 114 - 72 [s]- 115 - 73 [t]- 116 - 74 
    [u]- 117 - 75 [v]- 118 - 76 [w]- 119 - 77 [x]- 120 - 78 
    [y]- 121 - 79 [z]- 122 - 7A

ADVERTISEMENT
ADVERTISEMENT




Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.