Question 1:
What is the printed data?
#include<stdio.h>
int main() {
unsigned char i = 7;
int j = 0;
for (; i > 0; i -= 3) {
++j;
}
printf("%d\n", j);
return 0;
}
A.2 B. Infinite loop C.173 D.172
Parsing: C
Question 2:
Which of the following options must set the second bit of the flag to 0 ()
A. flag&=~2;
B.flag|=2;
c.flag^=2;
D.flag>>=2;
Analysis: A
Question 3:
In the case of #pragma(4) and #pragma(8), how much space does each occupy?
struct One {
double d;
char c;
int i;
};
struct Two {
char c;
double d;
int i;
};
A.16,24,16,24;
B.16,20,16,20;
C.16,16,16,24;
D.16,16,24,24;
Parsing: C
Question 4:
What is the printed data?
#include<stdio.h>
#include<stdio.h>
void main() {
int a = -3;
unsigned b = 2;
long c = a + b;
printf("%ld\n", c);
}
A.-1 ;
B.4294967295;
C.0x7FFFFFFF;
D.0xFFFFFFFF;
Analysis: A
Question 5:
What is the value of i?
int f(int x) {
return ((x > 2) ? x * f(x - 1) : 3);
}
int i = 1;
i = f(f(2));
A.30;
B. Infinite recursion;
C.9;
D.2160;
Parsing: C
Question 6:
The running result of fun(21) is ()
int fun(int x) {
a ^= (1 << 5) - 1;
return a;
}
A.10 B.5 C.3 D.8
Analysis: A
Topic 7:
Which of the following statements about C/C++ is incorrect:
A. The macro definition does not check the parameter type, which may cause security risks;
B. Macro-defined constants are easier to understand. If macro-defined constants can be used, avoid using const constants;
C. Too many nested definitions of macros will affect the readability of the program;
D. Compared with function calls, macro definitions can improve the running efficiency of the program;
Analysis: B
Question 8:
Which of the following descriptions about pointers is incorrect ()
A. After using the free function to release the content of a pointer, the value of the pointer variable was set to NULL;
B. The length of any type of pointer in 32-bit systems is 4 bytes;
C. The data type of the pointer declares the data type of the content actually pointed to by the pointer;
D. Wild pointers point to unallocated or released memory space;
Analysis: A