64 713
Assignments Done
99,4%
Successfully Done
In September 2018

Answer to Question #18779 in C++ for awesome

Question #18779
when does the following while loop terminate?
ch=’D’;
while(‘A’<=ch &&ch <=’Z’)
ch= static_cast<char>(static_cast<int>(ch)+1;

Expert's answer
That means that while ((ch>='A')&&(ch<='Z')){
static_cast <char> (static_cast<int> (CH) +1);}

this means that static_cast <int> (CH) +1) givesthe unicode of elemnt (for exemple for A it is smth like 60, and for B it is
61)
and static_cast <char> make again from int value ofunicode a char, so if we had ch='C', we receive ch='D', in on cycle.
Loop will terminate when ch would be equal to 'Z'+1

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions