Question: Carefully consider the following program: #include using namespace std; int main() { char ch; int ct1, ct2; ct1 = ct2 = 0; while ((ch =
Carefully consider the following program:
#include
using namespace std;
int main()
{
char ch;
int ct1, ct2;
ct1 = ct2 = 0;
while ((ch = cin.get()) != '$')
{
cout << ch;
ct1++;
if (ch = '$')
ct2++;
cout << ch;
}
cout <<"ct1 = " << ct1 << ", ct2 = " << ct2 << "\n";
return 0;
}
Suppose you provide the following input, pressing the Enter key at the end of each
line:
Hi!
Send $10 or $20 now!
What is the output? (Recall that input is buffered.)
Step by Step Solution
3.34 Rating (166 Votes )
There are 3 Steps involved in it
The output is as follows i If the whileloop condition is true then the salutation is printed ... View full answer
Get step-by-step solutions from verified subject matter experts
