Lab Program 1 - Binary, hex, decimal, ASCII & a function or two


Abstract

The purpose of this lab problem is to print the binary, hex, decimal, and ASCII values of the upper and lower case alphabet.

This problem will only work with the letters A through Z, upper and lower case.

The UPPER case letters will be converted to lower case by invoking the conversion function named ToLower. This function will only use bit manipulation to accomplish the conversion.

1 Objectives
1.1 Inputs
The only input is the name of the program - myHexLetters. No other command line parameters are required.

1.1.1 Command Line arguments

The program will be invoked as follows:

• myHexLetters

2 Process
The program myHexLetters will generate and display the upper and lower case letters from A through Z. The conversion will be accomplished on a character basis using bit manipulations described in more detail below.

2.1 char ToLower(char myLetter)
Description: Converts the UPPER case letter to a lower case letter.

Returns: The lower case letter that was passed as input.

Caveat: The conversion must be accomplished using bit manipulation not addition or subtraction. That is the conversion must be accomplished using an AND, OR, XOR, or NOT operation - as appropriate.

2.2 void printBinary(int someNum)
Description: Print the lower order 8 bits of an integer in binary.

Returns: Nothing.

Caveat: It is acceptable to use a loop over the 8 bits to determine if the bit under test is either a zero or a one. It is not acceptable to hard code the values of the 256 (or16) possible combinations.

3 Outputs
The output of the program will be for the upper & lower case letters A through Z. The outputs are shown below.

UPPER
lower
binary Hex Dec -
binary Hex Dec -
0100 0001
41 65 A
0110 0001
61 97 a
0100 0010
42 66 B
0110 0010
62 98 b
0100 0011
43 67 C
0110 0011
63 99 c
0100 0100
44 68 D
0110 0100
64 100 d
0100 0101
45 69 E
0110 0101
65 101 e
0100 0110
46 70 F
0110 0110
66 102 f
0100 0111
47 71 G
0110 0111
67 103 g
0100 1000
48 72 H
0110 1000
68 104 h
0100 1001
49 73 I
0110 1001
69 105 i
0100 1010
4a 74 J
0110 1010
6a 106 j
0100 1011
4b 75 K
0110 1011
6b 107 k
0100 1100
4c 76 L
0110 1100
6c 108 l
0100 1101
4d 77 M
0110 1101
6d 109 m
0100 1110
4e 78 N
0110 1110
6e 110 n
0100 1111
4f 79 O
0110 1111
6f 111 o
0101 0000
50 80 P
0111 0000
70 112 p
0101 0001
51 81 Q
0111 0001
71 113 q
0101 0010
52 82 R
0111 0010
72 114 r
0101 0011
53 83 S
0111 0011
73 115 s
0101 0100
54 84 T
0111 0100
74 116 t
0101 0101
55 85 U
0111 0101
75 117 u
0101 0110
56 86 V
0111 0110
76 118 v
0101 0111
57 87 W
0111 0111
77 119 w
0101 1000
58 88 X
0111 1000
78 120 x
0101 1001
59 89 Y
0111 1001
79 121 y
0101 1010
5a 90 Z
0111 1010
7a 122 z
It is acceptable to print the output in a single column, that is for the upper case letters first, then the lower case letters.
Powered by