46.4k views
2 votes
In order to store the newline character in a char variable named advanceToNextLine, you would write ____.a.advanceToNextLine = ‘\‘ + ‘n’;b.advanceToNextLine = ‘\\’;c.advanceToNextLine = "\\";d.advanceToNextLine = \\;

User Thesis
by
3.3k points

1 Answer

2 votes

Answer:

b. advanceToNextLine = ‘\\’;

Step-by-step explanation:

The syntax to use char data type is

char variable_name = 'character';

Note:

For char data type we always use single quotes and for string data type we use double quotes!

new-line character is represented by \\

Now lets arrange this information to create a variable named advanceToNextLine to store a new-line character in it.

char advanceToNextLine ='\\';

Hence the correct answer is option b

a. advanceToNextLine = ‘\‘ + ‘n’; syntax is wrong (invalid)

b. advanceToNextLine = ‘\\’; (valid)

c. advanceToNextLine = "\\"; double quotes are used (invalid)

d. advanceToNextLine = \\; single quotes are missing (invalid)

User Lucky Mike
by
2.7k points