Question: In Listing 6.2, what is the effect of replacing ++ch with ch+1? Heres some sample output from the program in Listing 6.2: Type, and I
In Listing 6.2, what is the effect of replacing ++ch with ch+1?

Here’s some sample output from the program in Listing 6.2:
Type, and I shall repeat.
An ineffable joy suffused me as I beheld
Bo!jofggbcmf!kpz!tvggvtfe!nf!bt!J!cfifme
the wonders of modern computing.
uif!xpoefst!pg!npefso!dpnqvujoh
Please excuse the slight confusion.
Note that one of the comments in Listing 6.2 suggests that changing ++ch to ch+1 has an interesting effect. Can you deduce what it will be? If not, try it out and then see if you can explain what’s happening.
Listing 6.2 1felse.cpp // ifelse.cpp - using the if else statement #include int main() { char ch; std::cout < < "Type, and I shall repeat. "; std::cin.get (ch); while (ch != 1.) { if (ch == ' ') std::cout < < ch; else // done if newline std::cout < < ++ch; // done otherwise std::cin.get (ch); } // try ch + 1 instead of ++ch for interesting effect std::cout < < " Please excuse the slight confusion. "; // std::cin.get(); // std::cin.get(); return 0;
Step by Step Solution
3.58 Rating (165 Votes )
There are 3 Steps involved in it
Replacing ch with ch1 in Listing 62 will cause the program to print out the character that was input ... View full answer
Get step-by-step solutions from verified subject matter experts
