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

Which of the following assignment statements are incorrect? i = 1; j = 1; k = 1;

ID: 3692432 • Letter: W

Question

Which of the following assignment statements are incorrect?

i = 1; j = 1; k = 1;

i = 1 = j = 1 = k = 1;

i == j == k == 1;

i = j = k = 1;

Suppose i is an int type variable. Which of the following statements display the character whose ASCII is stored in variable i?

cout << i;

cout << i;

cout << static_cast<int>i;

cout << static_cast<char>i;

i = 1; j = 1; k = 1;

i = 1 = j = 1 = k = 1;

i == j == k == 1;

i = j = k = 1;

Suppose i is an int type variable. Which of the following statements display the character whose ASCII is stored in variable i?

cout << i;

cout << i;

cout << static_cast<int>i;

cout << static_cast<char>i;

Explanation / Answer

i = 1 = j = 1 = k; is an incorrect statment because the syntax is invalid.

i == j == k == 1; is also an incorrect statement as multiple comparision operations cannot be performed in a single line command.

To display the character whose ascii code is stored in the variable i, we first have to typecast the variable to char type.

Therefore cout << static_cast<char> i; will display the corresponding character.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote