181k views
1 vote
Which statement allows you to properly check the char variable code to determine whether it is equal to a "C" and then output "This is a check" and then advance to a new line?

(A) If code is equal to Y



cout < < 'This is a check\\":



(B) If (code = "Y")



cout < < 'This is a check" < < endl:



(C) If (code == 'Y')



cout < < 'This is a check\\":



(D) If (code == Y)



cout < < 'This is a check" < < endl:

1 Answer

2 votes

Answer:

if (code == 'Y')

cout << "This is a check\\";

Step-by-step explanation:

I believe you want to check whether it is equal to "Y", because there is no option that checks "C". You may see the correct structure above, none of the option you provided is totally correct.

In order to check the character, we need to use if statement. Also, since "Y" is a character, we need to use ' ' not " ".

To output "This is a check", we need to use cout. The string should be inside " " not ' ' or ' ".

To have a new line, we may use \\. At the end, we need to use ; not :

User Guillem Gelabert
by
3.4k points