GESP: September 2024 C++ Level 2 Exam Questions and Analysis

The teacher has prepared an electronic printed version for everyone. Friends who need the complete electronic version can check at the end of the article.

【Answer Analysis】

1. Explanation: The answer is A.

This question examines the components of computer architecture. Memory in a computer is used to temporarily store data processed by the CPU and data exchanged with external storage devices like hard drives. The question emphasizes that the magnetic core component is a storage element in the control part of the computer’s operations, which is equivalent to the CPU in current computer components. As of September of the exam year, the storage structure of a general CPU is shown in the figure below, and the component most similar in function to the magnetic core is Cache, followed by Memory. Among the four options, the closest is option A.

2. Explanation: The answer is C.
Detailed analysis can be found in the figure below.

Review and expansion of related knowledge points:
As of September of the exam year, the allocation of IPV4 addresses is detailed in the figure below.

3. Explanation: The answer is A.

This question examines the naming rules for C++ variables. Variable names must meet the following criteria:
① Variable names can only consist of uppercase and lowercase letters, numbers, and underscores (_);
② The first character cannot be a number;
③ Variable names cannot be keywords (reserved words) in C++.
Option A contains other characters ‘-‘, which do not comply with the naming rules.

Review and expansion of related knowledge points:
The figure below shows the list of C++ keywords as of September of the exam year.

4. Explanation: The answer is C.
Detailed analysis can be found in the figure below.

5. Explanation: The answer is C.
Detailed analysis can be found in the figure below.

Review and expansion of related knowledge points:
As of September of the exam year, the operator precedence in C/C++ languages is detailed in the table below.

6. Explanation: The answer is D.
Detailed analysis can be found in the figure below.

Review and expansion of related knowledge points:
As of September of the exam year, the implicit conversion in C/C++ languages is detailed in the figure below.

7. Explanation: The answer is A.
Detailed analysis can be found in the figure below.

8. Explanation: The answer is A.
Detailed analysis can be found in the figure below.

Review and expansion of related knowledge points:
As of June of the exam year, the comparison of the mechanisms of the break and continue statements can be referenced in the image below.

9. Explanation: The answer is C.

Detailed analysis can be found in the figure below.
Review and expansion of related knowledge points:
As of September of the exam year, the mechanisms of logical operators in C/C++ languages are detailed in the table below.

10. Explanation: The answer is B.
Detailed analysis can be found in the figure below.
11. Explanation: The answer is C.
Detailed analysis can be found in the figure below.
12. Explanation: The answer is A.
Detailed analysis can be found in the figure below.
13. Explanation: The answer is A.

In the C++ statement while(1), 1 will be converted to true at runtime, which is a common way to write an infinite loop without syntax errors.
14. Explanation: The answer is B.
Detailed analysis can be found in the figure below.
15. Explanation: The answer is A.

【Answer Analysis】

1. Explanation: Correct.
C++ is a high-level language that supports object-oriented programming.

2. Explanation: Incorrect.
Detailed analysis can be found in the figure below.

Review and expansion of related knowledge points:
As of September of the exam year, the operation mechanism of the comma operator is illustrated with two examples in the figure below.

3. Explanation: Correct.
The function first calculates 10%2 = 2, then calculates 2%10 = 2, resulting in 2.

4. Explanation: Incorrect.
The function rand() is used to generate pseudo-random numbers and cannot guarantee which value will be larger in two calls.
Review and expansion of related knowledge points:
As of September of the exam year, the relevant knowledge points of random functions are detailed in the figure below.

5. Explanation: Incorrect.
Detailed analysis can be found in the figure below.
Review and expansion of related knowledge points:
As of September of the exam year, the general ASCII code table is detailed in the figure below.

6. Explanation: Correct.
Detailed analysis can be found in the figure below.
Review and expansion of related knowledge points:
As of September of the exam year, the differences in the mechanisms of executing break and continue statements within loops are explained in detail in the figure below.

7. Explanation: Incorrect.
Detailed analysis can be found in the figure below.
8. Explanation: Correct.
Detailed analysis can be found in the figure below.

9. Explanation: Correct.
Detailed analysis can be found in the figure below.
10. Explanation: Incorrect.
Detailed analysis can be found in the figure below.

GESP: September 2024 C++ Level 2 Exam Questions and Analysis

#include <iostream>
using namespace std;
int judge(int num){
    int total=0;
    while(num>0)
    {
        total=total+num%10;
        num=num/10;
    }
    return total;
}
const int N=1E5+5;
int arr[N];
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    for(int i=0;i<n;i++)
    {
        if(judge(arr[i])%7==0)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}

GESP: September 2024 C++ Level 2 Exam Questions and AnalysisGESP: September 2024 C++ Level 2 Exam Questions and AnalysisGESP: September 2024 C++ Level 2 Exam Questions and Analysis

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(j==1||j==n)
            {
                cout<<"+";
            }
            else
            {
                if(i==j)cout<<"+";
                else cout<<"-";
            }
        }
        cout<<"\n";
    }
}
Learning Path——

Friends who need a watermark-free PDF format file are welcome to scan the QR code below to add friends for consultation.

▍ Declaration: This article is compiled from the internet. If there is any infringement, please contact us for deletion.

This public account publishes this article for the purpose of legally and reasonably sharing and disseminating information, expanding the audience range, promoting academic exchanges, and advancing mutual progress. The public account holder solemnly declares that the publication of this article will strictly comply with relevant regulations and laws, will not infringe on any potential author's rights, and will not change the intent and content of the original citation (if any). If there are any errors in source attribution or infringement of your legitimate rights, please feel free to contact us for negotiation. Contact (QQ): 993225721, we will correct and delete it in a timely manner.

If this article is fortunate enough to be reprinted, first, the public account holder thanks the reprinter for providing valuable information and knowledge for readers. We hope the article can be more widely disseminated and exchanged on the platform where it is reprinted. Secondly, the reprinter should fully consider the potential risks and responsibilities that may arise from the act of reprinting, including but not limited to legal responsibilities arising from infringement of intellectual property rights and infringement of others' rights, ensuring the legal dissemination and use of this article. At the same time, I am also very willing to cooperate with the reprinter to understand, pay attention to, avoid, and eliminate related potential risks during the reprinting process. If the reprinter has any relevant concerns, they are also welcome to contact us for negotiation. Contact (QQ): 993225721.

We hope you will follow us——

Leave a Comment