Question: Given the following input in the input stream, what would be stored in the variables after the following code executes. // Input stream : ab1%2Yu9

Given the following input in the input stream, what would be stored in the variables after the following code executes.

// Input stream : ab1%2Yu9

char ch;

cin.get(ch);

cout << "#Output 1 " << ch << endl;

cin.ignore(5, '%');

ch = cin.peek();

cout << "#Output 2 " << ch << endl;

cin.get(ch);

cin.putback(ch);

cin.get(ch); cout << "#Output 3 " << ch << endl; cin.get(ch); cout << "#Output 4 " << ch << endl;

system("pause");

return 0;

#Output 1 =

#Output 2 =

#Output 3 =

#Output 4 =

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!