wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quarter3_Quiz_no.2: C++ Character Data Types

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

A student writes the following code:

char x = 97;

cout << x;

What higher-level reasoning best explains why the output is ‘a’?

a)

Because character variables automatically convert to lowercase letters

b)

Because 97 is directly mapped to ‘a’ in the ASCII table

c)

Because the compiler detects a numeric literal and forces a cast to char

d)

Because numeric values always represent letters in C++

2.

You want to store the symbol ‘&’ using its ASCII value. Which reasoning correctly identifies the value you should assign?

a)

Choose any integer between 0 and 127, because ASCII allows any value

b)

Use the ASCII code that the compiler decides at runtime

c)

Look up the ASCII table and assign the number representing ‘&’

d)

Choose the Unicode value because ASCII is outdated

3.

A student declares:

char c = '\n';

Why will printing this variable not show an actual character?

a)

Because '\n' deletes characters

b)

Because '\n' is an escape sequence that represents an action, not a visible symbol

c)

Because escape sequences are always ignored

d)

Because char cannot hold escape sequences

4.

Consider the line:

char d = '\\';

Why must a double backslash be used?

a)

Because the compiler rejects single character declarations

b)

Because the backslash is reserved for starting escape sequences

c)

Because two backslashes represent a space

d)

Because ASCII requires paired slashes

5.

Which scenario BEST demonstrates implicit type conversion between char and int?

a)

Assigning a char to another char variable

b)

Subtracting two char variables to compare letters

c)

Converting a float to char

d)

Using char inside a string

6.

Why does the following cause an error?

string s = "He said "Hello" today.";

a)

Because strings cannot contain uppercase letters

b)

Because quotes inside a string must be escaped using "

c)

Because C++ requires single quotes for strings

d)

Because escape sequences cannot appear inside strings

7.

What would be the output of this code and why?

char a = '7';

char b = 7;

cout << a << b;

a)

Both output the character ‘7’ because integers convert to strings

b)

‘7’ followed by a non-printable control character because ASCII 7 is BEL

c)

Two numeric values printed directly

d)

Runtime error due to invalid char assignment

8.

A student writes:

char x = char(65 + 32);

What is the output and why?

a)

‘a’ because ASCII math transforms uppercase letters to lowercase

b)

‘A’ because char() removes addition

c)

65 because char cannot store numerical expressions

d)

Compiler error due to type mismatch

9.

Which reasoning correctly explains why this code prints on two lines?

cout << "HEY\nHEY";

a)

The compiler inserts an automatic newline after every string

b)

'\n' instructs the output stream to create a new line

c)

Strings must always be printed on separate lines

d)

C++ ignores the newline character

10.

What is the most logical reason for grouping escape sequences with the char data type?

a)

Escape sequences represent actions stored as a single encoded character

b)

Escape sequences must always be stored as strings

c)

Escape sequences require more than one byte

d)

Escape sequences contain numbers, not characters

11.

Which BEST explains why this code prints:

cout << int('$');

a)

The compiler converts '$' into its ASCII integer value

b)

Characters cannot be printed directly

c)

Characters are automatically converted to strings

d)

‘$’ has no printable ASCII representation

12.

You need to check whether the char stored is an uppercase letter. Which HOTS reasoning is correct?

a)

Compare it to ASCII range 97–122

b)

Compare it to ASCII range 65–90

c)

Convert the char into a string for comparison

d)

Use escape sequences to detect letter type

13.

What is the reasoning behind using ASCII numeric declarations such as:

a)

It saves memory

b)

It allows characters to be represented without literal symbols

c)

It prevents escape sequence errors

d)

It avoids the need for the char keyword

14.

A student types:

char x = '\t';

cout << "A" << x << "B";

What higher-order explanation describes the spacing effect?

a)

'\t' inserts a horizontal tab, increasing spacing between A and B

b)

'\t' is ignored unless inside loops

c)

'\t' removes characters between A and B

d)

'\t' prints a letter ’t’

15.

Suppose you want to display this output:

He said "Stop!"

Which option shows correct reasoning?

a)

Use single quotes to avoid escape sequences

b)

Escape the inner quotes because they conflict with string delimiters

c)

Avoid using quotation marks inside C++

d)

Insert ASCII values instead of characters