Table of contents
1.1. The number of executions of the following for loop is ( )
1.2. The result after the execution of the following main() function is ()
2.1. What is the output of the following program? ( )
Recommended reading order:
1. Topic -> 3. Answer -> 2. Topic analysis -> 4. Topic knowledge points
1. for loop
1.1. The number of executions of the following for loop is ( )
for(int x = 0, y = 0; (y = 123) && (x < 4); x++);
A: infinite loop B: variable number of loops C: 4 times D: 3 times
1.1.1. Topic analysis
This is a typical question for sending points to investigate the for loop.
It's better to watch by number
1.1.2. Question answer
C: 4 times
1.2. The result after the execution of the following main() function is ()
int func(){
int i, j, k = 0;
for(i = 0, j = -1;j = 0;i++, j++){
k++;
}
return k;
}
int main(){
cout << (func());
return 0;
}
A:-1 B: 0 C: 1 D:2
1.2.1. Topic Analysis
This is another very typical question for sending points to investigate the for loop.
It's better to watch by number
1.2.2. Question answer
B:0
2. Logical OR
2.1. What is the output of the following program? ( )
#include <stdio.h>
int main()
{
int a=1,b=2,c=3,d=0;
if(a == 1 && b++==2)
if(b!=2||c--!=3)
printf("%d,%d,%d\n" ,a,b,c);
else
printf("%d,%d,%d\n" ,a,b,c);
else
printf("%d,%d,%d\n" ,a,b,c);
return 0;
}
A :1,2,3 B :1,3,2 C :3,2,1 D: 1,3,3
2.1.1. Topic analysis
This is a typical question about examining if conditional statements and logical operators.
It's better to watch by number
2.1.2. Question answer
D: 1,3,3
at last
I can only say that you should read often and always be new, and you still need to review it frequently. The understanding of small points is still not deep enough, so take this as a warning.