Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the following problems. 1. Suppose you are given the following variable

ID: 3627270 • Letter: C

Question

Complete the following problems.

1. Suppose you are given the following variable declarations:

int x, y;
char ch;

What values (if any) are assigned to x, y, and ch after each of these statements execute?
Assume that the input to each statement is the same: 5 28 36

a. cin >> x >> y >> ch;
b. cin >> ch >> x >> y;
c. cin >> x >> ch >> y;
d. cin >> x >> y;
cin.get(ch);

2. Suppose you are given the following variable declarations:

int x, y;
char ch;

What values (if any) are assigned to x, y, and ch after each of these statements execute?
Assume that the input to each set of statements is as follows:

13 28 D
14 E 98
A B 56

a. cin >> x >> y;
cin.ignore(50, ' ');
cin >> ch;

b. cin >> x;
cin.ignore(50, ' ');
cin >> y;
cin.ignore(50, ' ');
cin.get(ch);

3. Suppose you are given the following variable declarations:

int x, y;
double z;
char ch;

Assume you have the following input statement:

cin >> x >> y >> ch >> z;

What values (if any) are stored in x, y, z, and ch if the input is:

a. 35 62. 78
b. 86 32A 92.6
c. 12 .45A 32

4. Write a C++ statement that uses the manipulator 'setfill' to output a line containing 35 asterisk characters.

5. What is the output from the following statements?

a. if ( 60 <= 12 * 5)
cout << "Hello";
cout << " There";

b. if ('a' > 'b' || 66 > static_cast<int>('A'))
cout << "#*#" << endl;

c. if (7 <= 7)
cout << 6 - 9 * 2 / 6 << endl;

d. if (7 < 8)
{
cout << "2 4 6 8" << endl;
cout << "1 3 5 7" << endl;
}

e. if (5 < 3)
cout << "*";
else if (7 == 8)
cout << "&";
else
cout << "$";

Explanation / Answer

http://www.austincc.edu/comer/1320u03/rev1ans.htm

it will solve your questions