Daily C++ Challenge – Day 897

Today marks the 897th day of learning programming with the cool drizzle!

Hello, everyone! This is the test for GESP202509 Level 2.

Day 897

Daily C++ Challenge - Day 897Daily C++ Challenge - Day 897

GESP202509 Level 2

Multiple Choice Question

Question 9

For Question 9, read the following C++ code, where all variables are integers. Which statement is correct ( )?

Daily C++ Challenge - Day 897

A. b cannot be 0, as a % b will cause an error

B. a must be less than b, otherwise a % b will cause an error

C. Both a and b must be positive integers, otherwise a % b will cause an error

D. If a is input as 0, regardless of the input value of b, the output value’s absolute value is always abs(b)

Answer: D

START OF SPRING

Solution:This question tests the greatest common divisor.

Option A: b can be 0, but the while loop will not execute.

Option B: There is no necessary size relationship between a and b.

Option C: b can be 0.

Option D: This option is correct. If a is 0 and b is 0, printing the value of a will definitely be the same as the absolute value of b. If a is 0 and b is not 0, the while loop executes once, assigning the value of b to a. Therefore, all printed values’ absolute values will be the same as the absolute value of b.

Daily C++ Challenge - Day 897

20

25

11

Daily C++ Challenge - Day 897

NOVEMBER

Day

Monday

Tuesday

Wednesday

Thursday

Friday

Saturday

1

12

2

13

3

14

4

15

5

16

6

17

7

Beginning of Winter

8

Chinese Journalist Day

9

Fire Safety Day

10

21

11

22

12

23

13

24

14

25

15

26

16

27

17

28

18

29

19

30

20

October

21

Second Day

22

Light Snow

23

Fourth Day

24

Fifth Day

25

Sixth Day

26

Seventh Day

27

Thanksgiving

28

Ninth Day

29

Tenth Day

30

Eleven

Cool Drizzle

Cool Drizzle

Open Wisdom Station

Daily C++ Challenge - Day 897

Leave a Comment