Please i need some explanation here. Program to display lowercase to uppercase letters. Guys thanks so much. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Please i need some explanation here. Program to display lowercase to uppercase letters. Guys thanks so much.

Please can someone explain to me why static_cast<int> is use then after static_cast <char> is used. Why not to use satatic_cast <int> only or <char> only for both lines. #include <iostream> Using namespace std; int main () { char inchar, outchar; int inIntchar, outIntchar; cout << "enter the lowercase char" ; cin >> inChar; inIntchar = static_cast<int>(inChar); outIntChar = inIntchar - 32; outChar = static_cast<char>(outIntchar); cout << "The uppercase letter you entered is" <<outChar;

18th Feb 2019, 11:33 AM
Jabir
Jabir - avatar
2 Answers
+ 2
Thanks guys. The explanation are helpful
18th Feb 2019, 6:21 PM
Jabir
Jabir - avatar
0
I'm not familiar with c++, but I think that you need int for the ascii value of the lowercase char. For example: char input = b int input = 98 int output = 98 - 32 = 66 char output = B Ascii-table: https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.ioaq100/ascii_table.gif
18th Feb 2019, 2:11 PM
Denise Roßberg
Denise Roßberg - avatar