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.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.