To write a program to convert lowercase to uppercase or to convert uppercase to lowercase, we need to use the ASCII values of the letters. This can be an amazing beginner level project as a C++ programmer. If you want to know how to convert lowercase letters to uppercase or vice versa using C++, this article is for you. In this article, I will introduce you to a tutorial on how to write a C++ program to convert lowercase to uppercase of a letter and vice versa.
C++ Program to Convert Lowercase to Uppercase
To understand the logic behind converting a lowercase letter to uppercase or vice versa, you need to understand the full ASCII table. It stands for American Standard Code for Information Interchange. It is nothing more than a character encoding standard for electronic communications. Below is the full ASCII table that will help you understand the logic behind writing a program to convert lowercase to uppercase or vice versa.
Letter | ASCII Code | Binary | Letter | ASCII Code | Binary |
---|---|---|---|---|---|
a | 97 | 1100001 | A | 65 | 1000001 |
b | 98 | 1100010 | B | 66 | 1000010 |
c | 99 | 1100011 | C | 67 | 1000011 |
d | 100 | 1100100 | D | 68 | 1000100 |
e | 101 | 1100101 | E | 69 | 1000101 |
f | 102 | 1100110 | F | 70 | 1000110 |
g | 103 | 1100111 | G | 71 | 1000111 |
h | 104 | 1101000 | H | 72 | 1001000 |
i | 105 | 1101001 | I | 73 | 1001001 |
j | 106 | 1101010 | J | 74 | 1001010 |
k | 107 | 1101011 | K | 75 | 1001011 |
l | 108 | 1101100 | L | 76 | 1001100 |
m | 109 | 1101101 | M | 77 | 1001101 |
n | 110 | 1101110 | N | 78 | 1001110 |
o | 111 | 1101111 | O | 79 | 1001111 |
p | 112 | 1110000 | P | 80 | 1010000 |
q | 113 | 1110001 | Q | 81 | 1010001 |
r | 114 | 1110010 | R | 82 | 1010010 |
s | 115 | 1110011 | S | 83 | 1010011 |
t | 116 | 1110100 | T | 84 | 1010100 |
u | 117 | 1110101 | U | 85 | 1010101 |
v | 118 | 1110110 | V | 86 | 1010110 |
w | 119 | 1110111 | W | 87 | 1010111 |
x | 120 | 1111000 | X | 88 | 1011000 |
y | 121 | 1111001 | Y | 89 | 1011001 |
z | 122 | 1111010 | Z | 90 | 1011010 |
I hope you have understood the ASCII table shown above. The only things that you should take away from the above table for writing this program are:
- 65 to 90 = A to Z
- 97 to 122 = a to z
Now below is how you can write a C++ program to convert a letter with lowercase to uppercase or vice versa:
Summary
So this is how you can write a program for converting the lowercase of a letter to uppercase or vice versa by using the C++ programming language. This can be an amazing beginner level project as a C++ programmer. I hope you liked this article on how to write a C++ program to convert lowercase to uppercase or vice versa using C++. Feel free to ask your valuable questions in the comments section below.