CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 6

6. Write a program which accepts a character and display its ASCII value.

For this particular assignment, I was not exactly sure how to execute it.  After a quick Google search, I found a website that explained everything, specifically Programiz.  According to Programiz,

"A character variable holds ASCII value (an integer number between 0 and 127) rather than that character itself in C programming. That value is known as ASCII value.

For example, ASCII value of 'A' is 65.
What this means is that, if you assign 'A' to a character variable, 65 is stored in that variable rather than 'A' itself."

Also, here is a handy ASCII Chart that details all of the characters values, specifically in dec, oct, and hex.  Admittedly, the Programiz website explained things a bit too easily, which included example code of the conversion.  Nevertheless, I went ahead and coded my own snazzy rendition.  See below.




Of course, everything worked as expected. 




However, it is always important to check to ensure the results are correct.  Sure enough, "a is 97" is correct!  See the ASCII Chart below.




Comments

Popular posts from this blog

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 9

CPPForSchool.com: Array - Single Dimension Set 1 Assignment 6

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 8