Carefully consider the following program: #include using namespace std; int main() { char ch; int ct1, ct2;

Question:

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.)

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

C++ Primer Plus

ISBN: 9780321776402

6th Edition

Authors: Stephen Prata

Question Posted: