Raj Kumar Raj Kumar - 4 months ago 16
C++ Question

C++ : How to reduce conditional statements

I am new to programming and I have to write the code which will print the ASCII value of an input character. Is there any other way to reduce the 52 (26 for lowercase and 26 for upper)

if-else
statements or 52
switch-cases
?

Answer

Because it's not clear what you are trying to do, your question is not very well written. However, I think you need to take a look at typecasting.

Try this statement to convert the character to the corresponding ASCII value:

int output = (int)inputCharacter;
Comments