Multiple Choice Questions
Question 1: Which of the following is not a computer output device? ()
A. Microphone
B. Speaker
C. Printer
D. Monitor
【Answer】A
【Explanation】Basic Computer Knowledge
Microphone is an input device;Common input devices: mouse, keyboard, microphone, etc.;Common output devices: computer screen, speakers, printers, etc.
Question 2: ChatGPT is a chatbot program developed by OpenAI. It can converse by understanding and learning human language and can interact based on the context of the conversation to complete many tasks. Can you guess which of the following tasks ChatGPT cannot accomplish? ()
A. Writing a script
B. Editing an email
C. Mopping the floor
D. Writing code
【Answer】C
【Explanation】Basic Computer Knowledge
Question 3: The data type of the constant ‘3’ is ()
A. double
B. float
C. char
D. int
【Answer】C
【Explanation】Common Variable Types:
1. Integer types (int, long, long long);
2. Floating-point types (float, double);
3. Character types (char);
4. Boolean types (bool).
Question 4: Which of the following statements about C++ language variables is correct? ()
A. Variables can be undefined
B. Assigning a value to an undefined variable is equivalent to defining a new variable
C. After executing the assignment statement, the type of the variable may change
D. After executing the assignment statement, the value of the variable may not change
【Answer】D
【Explanation】Variable Examination
Option A: Variables must be declared (defined) before use;
Option B: Undefined variables cannot be used, hence cannot be assigned;
Option C: Variables must be declared before use, and their type does not change upon use;
Therefore, Option D is correct.
Question 5: Which of the following can be used as a C++ identifier? ()
A. number_of_Chinese_people_in_millions
B. 360AntiVirus
C. Man&Woman
D. break
【Answer】A
【Explanation】Variable Naming Rules
Option B: Starts with the digit 3;
Option C: Contains the & symbol;
Option D: Is a reserved word (keyword).
Knowledge Points:
1. Variable composition: letters, digits, and underscores;
2. Variable naming: must start with a letter or underscore.

Question 6: Which of the following is not a C++ keyword? ()
A. double
B. else
C. while
D. endl
【Answer】D
【Explanation】Keyword Examination
Question 7: If a, b, and c are all int type variables, which of the following statements does not conform to C++ syntax? ()
A. a = (b == c);
B. b = 5.5;
C. c = a + b + c;
D. a + c = b + c;
【Answer】D
【Explanation】Expression Examination, Option D cannot have an expression on the left side of the equals sign.
Knowledge Points:
1. Expression –> an equation that returns a value;
2. Expressions can be connected by operators;
3. Operators include:
Arithmetic operators: +, -, *, /, %
Relational operators: <>, <=, >=, !=, ==
Logical operators: &&, ||, used to connect boolean variables
Assignment operator: =
Question 8: If an int type variable a represents the length of a side of a square, which of the following expressions cannot be used to calculate the area of the square? ()
A. a * a
B. 1 * a * a
C. a ^ 2
D. a * 2 * a / 2
【Answer】C
【Explanation】Operator Examination
Option C: In C++, ^ represents the XOR operation
Question 9: The result of the expression (4 * (11 + 12) / 4) is ().
A. 47
B. 20
C. 23
D. 56
【Answer】C
【Explanation】Expression Application
Question 10: If a is an int type variable and its value is 6, then after executing a %= 4;, the value of a will be ().
A. 1
B. 2
C. 3
D. 4
【Answer】B
【Explanation】% modulus operator; a %= 4 means a = a % 4; 6 divided by 4 gives a remainder of 2, so a’s value is 2.
Question 11: If both a and b are int type variables, which of the following expressions can correctly determine “a equals 0 and b equals 0”? ()
A. (a == b == 0)
B. !(a || b)
C. (a + b == 0)
D. (a == 0) + (b == 0)
【Answer】B
【Explanation】Logical Operator Application
*Judgment Method: Listing Method or Counterexample

The image above shows that Option B satisfies the question “a equals 0 and b equals 0”.
Knowledge Points:
1. And: &&
2. Or: ||
3. Equals: relational operator ==
Question 12: If a and b are int type variables with values 7 and 2 respectively, which of the following expressions does not yield a result of 3.5? ()
A. 0.0 + a / b
B. (a + 0.0) / b
C. (0.0 + a) / b
D. a / (0.0 + b)
【Answer】A
【Explanation】Expression Application; In computing, 7/2=3, 7.0/2=3.5.
Question 13: Fill in the blanks in the following code to output “20 10”.

A. a + b
B. b
C. a – b
D. b – a
【Answer】C
【Explanation】By backtracking with a=10 and b=20, we find that in line 7, a= -10, in line 6, b=20, then substituting each option.
Question 14: Fill in the blanks in the following code to output “147”.

A. i % 2 == 1
B. i % 3 == 1
C. i = i + 3
D. i + 3
【Answer】B
【Explanation】
Method: 1. Find the pattern (the numbers in the question “1, 4, 7” all yield 1 when taken modulo %)
2. Substitute the options
Option A: yields 1, 3, 5, 7;
Option B: yields 1, 4, 7;
Options C and D: are distractors.
Question 15: After executing the following C++ program, what will be the output? ()

A. 63
B. 98
C. 113
D. Cannot be determined
【Answer】D
【Explanation】Because the variable sum in line 4, int sum;, is not initialized, the sum in cout cannot be determined.
True or False Questions
Question 1: Computer hardware mainly includes the arithmetic unit, control unit, memory, input devices, and output devices.
True
False
【Answer】√
【Explanation】Computer Knowledge
Question 2: The 103 machine, born in 1958, is China’s first general-purpose digital electronic computer, which is more than a decade later than the first general-purpose electronic computer ENIAC born in the USA in 1946.
True
False
【Answer】√
【Explanation】Computer Knowledge
Question 3: In C++ language, the calculation result must be stored in a variable to be output.
True
False
【Answer】×
【Explanation】Variable Examination
Question 4: In C++ language, an identifier’s name cannot consist entirely of digits; at least one letter is required.
True
False
【Answer】×
【Explanation】Variable Naming Rules
1. Variable composition: letters, digits, and underscores;
2. Variable naming: must start with a letter or underscore.
Question 5: 10 is an int type constant.
True
False
【Answer】√
【Explanation】Data Type Examination
Question 6: An if statement can have no else clause.
True
False
【Answer】√
【Explanation】if Statement Examination
Question 7: A do … while statement’s loop body will execute at least once.
True
False
【Answer】√
【Explanation】Loop Statement Examination,
Question 8: If a and b are int type variables, the expression a = b can determine whether a and b are equal.
True
False
【Answer】×
【Explanation】Operator Application
The “=” is the assignment operator; “==” is the relational operator, used to determine if a and b are equal.
Question 9: If a is an int type variable, the expression (a % 4 == 2) can determine if the value of a is even.
True
False
【Answer】×
【Explanation】To determine if a is even (a%2=0); using (a%4==2), for example, when a=4, 4%4=0, 4 is even, so it cannot be determined.
Question 10: The result of the expression (37 / 4) is 9, and the result type is int.
True
False
【Answer】√
【Explanation】Expression Application; int/int=int type, 37/4=9.
Programming Questions
Question 1: Time Planning
【Problem Description】
Xiao Ming is planning his study time. Now he wants to know how many minutes are between two moments; can you help him do this through programming?
【Input Description】
Input 4 lines, the first line is the starting hour, the second line is the starting minute, the third line is the ending hour, and the fourth line is the ending minute. Input guarantees that the two moments are on the same day, and the starting moment is always before the ending moment. The time uses the 24-hour system, with hours between 0 and 23 and minutes between 0 and 59.
【Output Description】
Output one line containing an integer, indicating how many minutes are between the starting and ending moments.
【Sample Input 1】
9
5
9
6
【Sample Output 1】
1
【Sample Input 2】
9
5
10
0
【Sample Output 2】
55
Question 2: Cumulative Addition
【Problem Description】
Input a positive integer n, calculate the cumulative addition in the form: 1+(1+2)+(1+2+3)+(1+2+3+4)+……+(1+2+3+4+5+……+n).
【Input Description】
Input a positive integer. It is stipulated that 1<n≤100.
【Output Description】
Output the result of the cumulative addition.
【Sample Input 1】
3
【Sample Output 1】
10
【Sample Input 2】
4
【Sample Output 2】
20
【Sample Input 3】
10
【Sample Output 3】
220
Previous Selections

【CSP-J/S Informatics Training Camp】
“All-Star” Coach Lineup

【Informatics Monthly Competition】
CSP-J June Simulation Exam Questions Analysis

14th Blue Bridge Cup National Competition for Youth
C++ Exam Questions Analysis

