C language programming test 2 (with reference)
Range: 1 ~ Chapter 6
Questions
I. Single-choice questions (1 ~ 30 questions, 1 point per question; 31 ~ 40 questions, 2 points per question; 50 points in total)
1. If the following definitions are available:
Char S = '/072 ';
The statement:
(A) The value of S contains 1 character (B). The definition is invalid, and the value of S is uncertain.
(C) Make the value of S contain four characters (d) so that the value of S contains three characters
2. the invalid C escape characters in the following options are:
(A) '/t' (B)'/017 '(c)'/N' (d) '/0xaa'
3. The C language expression that does not correctly represent the mathematical expression a * B/(c * D) is: (Note: replace small dots)
(A) a * B/c * D (B) A/(c * D) * B (c) a * B/c/d (d) A * B/(c * D)
4. Which of the following identifiers cannot be user-defined identifiers:
(A) AB _2 (B) If (c) _ 123 (d) A_3
5. The C language program is composed:
(A) subroutine (B) process (c) function (d) main program and subroutine
6. The following identifiers are valid user identifiers:
(A) P # A (B) A10 (c) void (d) 10a
7. The incorrect values in the following data are:
(A) 0.0 (B) 5l (c) 3e3. 5 (d) 986
8. The incorrect character constants in the following data are:
(A) "C" (B) '/N' (c)'/041 '(d) 'C'
9. In the following integer, the incorrect octal or hexadecimal number is:
(A) 0x16 (B) 016 (c)-16 (d) 0 xaaaa
10. The types of known variables are defined as follows:
Int I = 8, K, A, B;
Unsigned long w = 5;
Double X = 1.42, y = 5.2;
In the following options, the expressions that do not conform to the C language syntax are:
(A) k = I ++; (B) (INT) x + 0.4 (c) Y + = x ++; (d) a = 2 * A = 3
11. In the following options, the assignment statement that does not conform to the C language syntax is:
(A) A = 1, B = 2 (B) ++ I; (c) a = B = 5; (d) y = (a = 3,6*5 );
12. In the following options, the valid C language keyword is:
(A) INTEGER (B) Char (c) int (d) Real
13. Which of the following statements are false:
(A) variables used in the C program must be defined first and then used
(B) In C Programs, APH and APH are two different variables.
(C) If a and B are of the same type, after the value assignment statement A = B is executed, the value in B is placed in,
The value in B remains unchanged.
(D) When a numeric value is input, only the integer value can be input for an integer variable; for a real variable, only
Can input real value
14. If the ASCII code of character a is 97 in decimal format, the output of the following program is:
Main ()
{
Char C1, C2;
C1 = 'A' + '6'-'2 ';
C2 = 'A' + '6'-'3 ';
Printf ("% C, % d/N", C2, C1 );
}
(A) Output undefined values (B) d, 100 (c) D, C (d) d, 101
15. In C, to end the loop composed of the while statement
The expression value should be:
(A) 0 (B) 1 (c) True (d) Non-0
16. In C, to end the loop composed of the do-while statement
The expression value in parentheses should be:
(A) 0 (B) 1 (c) False (d) Non-0
17. In C language, the expression used to determine the branch flow in a pair of parentheses after the if statement is:
(A) Only logical expressions can be used. (B) only relational expressions can be used.
(C) Only logical expressions or relational expressions can be used. (d) any expressions can be used.
18. Among the following operators, the operator with the highest priority is:
(A) <= (B)/(c )! = (D )&&
19. Among the following operators, the operator with the highest priority is:
()! (B) = (c) + (d) |
20. In the following expression... The (e) Non-equivalent expression in the while (e) statement is:
()(! E = 0) (B) (E> 0 | E <0) (C) (E = 0) (D) (E! = 0)
21. In C language, the type of the expression in a pair of parentheses after the switch statement:
(A) can be any type (B) can only be int type
(C) It can be an integer or numeric type (d). It can only be an integer or a real type.
22. The C language source program extension is:
(A). C (B). BAT (c). EXE (d). Lib
23. The following expression cannot meet the requirements: when the value of X is an even number, its value is true. If it is an odd number, its value is false:
(A) x % 2 = 0 (B )! X % 2! = 0 (c) (X/2 * 2-x) = 0 (d )! (X % 2)
24. In C, which can represent the true logic value is:
(A) True (B) number greater than 0 (c) Number of non-0 integers (d) Non-0
25. If both A, B, and C are int variables, and a = 3, B = 4, C = 5, then in the following expression,
The expression with a value of 0 is:
(A) 'A' & 'B' (B) A <= B
(C) A | B + C & B-c (d )! (A <B )&&! C | 1)
26. If both X and Y are int variables, x = 100, y = 200, and the following program snippets exist:
Printf ("% d", (x, y ));
The output result of the above program fragment is:
(B) 200 (B) 100
(C) 100 200 (d) Insufficient output format characters, output uncertain values
27. If K is an int-type variable and has the following program snippet:
K =-3;
If (k <= 0) printf ("####");
Else printf ("&&&&");
The output result of the above program fragment is:
(A) #### (B )&&&&
(C) #####& & (d) syntax errors and no output results
28. In C language, the Operation number must be an integer OPERATOR:
(A) % (B)/(c) <(d )!
29. The output of the following program is:
(A) 0 (B) 1 (c) 3 (d) uncertain values
Main ()
{
Int x = 10, y = 3;
Printf ("% d/N", y = x/y );
}
30. After executing the output statement in the following program, the value of a is:
(A) 65 (B) 20 (c) 15 (d) 10
Main ()
{
Int;
Printf ("% d/N", (a = 3*5, a * 4, A + 5 ));
}
31. The output of the following program is
(A) 0 0 3 (B) 0 1 2
(C) 1 0 3 (d) 1 1 2
Main ()
{
Int A =-1, B = 4, K;
K = (a ++ <= 0 )&&(! (B -- <= 0 ));
Printf ("% d/N", K, a, B );
}
32. The mathematical function relation expressed in the following program fragment is
(A)-1 (x <0) (B) 1 (x <0)
Y = 0 (x = 0) y =-1 (x = 0)
1 (x = 0) 0 (x> 0)
(C) 0 (x <0) (d)-1 (x <0)
Y =-1 (x = 0) y = 1 (x = 0)
1 (x> 0) 0 (x> 0)
Y =-1;
If (X! = 0)
If (x> 0) y = 1;
Else y = 0;
33. The output of the following program is:
(A) 741 (B) 852 (c) 963 (d) 875421
Main ()
{Int y = 9;
For (; y> 0; y --)
{
If (Y % 3 = 0)
{Printf ("% d", -- y); continue ;}
}
}
34. The simplest Data Types in C include:
(A) integer, real, logical (B) integer, real, and complex
(C) integer, real, logical (d) integer, real, logical, and complex
35. The C language expression is used to indicate the relationship x ≥y ≥z:
(A) (x> = y) & (Y> = z) (B) (x> = Y) and (y> = z)
(C) (x> = Y> = z) (D) (x> = y) & (Y> = z)
36. The output result of the following program is:
Main ()
{
Int x = 10, y = 10;
Printf ("% d/N", X --, -- y );
}
(A) 10 10 (B) 9 9 (c) 9 10 (d) 10 9
37. The output result of the following program segments is:
Int x = 3;
Do
{
Printf ("% 3d", X-= 2 );
}
While (! (-- X ));
(A) 1 (B) 3 0 (c) 1-2 (d) endless Loops
38. If K is an integer, The WHILE LOOP
K = 0;
While (k = 0) k = K-1;
(A) 1 execution (B) infinite loop
(C) Neither execution at a time (d) Execution twice
39. Run the following program twice. If you enter 6 and 4 on the keyboard, the output result is
Main ()
{
Int X;
Scanf ("% d", & X );
If (x ++> 5) printf ("% d/N", X );
Else printf ("% d/N", X --);
}
(A) 7 and 5 (B) 6 and 3 (c) 7 and 4 (d) 6 and 4
40. The relational expression that correctly represents a ≥10 or a ≤0 is
(A) A> = 10 or a <= 0 (B) A> = 10 | A <= 0
(C) A> = 10 | A <= 0 (d) A> = 10 & A <= 0
(Note: the original question options C and D are the same, and this question is slightly modified)
2. Write the running result of a program or program segment. (4 points per question, 20 points in total)
1. Main ()
{
Int num = 0;
While (Num <= 2)
{
Num ++;
Printf ("% d/N", num );
}
}
The output result of the above program is _______________.
2. Main ()
{
Float X, Y;
Scanf ("% F", & X );
If (x <0.0) y = 0.0;
Else if (x <5.0) & (X! = 2.0 ))
Y = 1.0/(x + 2.0 );
Else if (x <10.0) y = 1.0/X;
Else y = 10.0;
Printf ("% F/N", y );
}
If you type 2.0 on the keyboard during running, the output result of the above program is _______________.
3. Main ()
{Int x = 1, y = 0, a = 0, B = 0;
Switch (X)
{
Case 1:
Switch (y)
{
Case 0: A ++; break;
Case 1: B ++; break;
}
Case 2:
A ++; B ++; break;
}
Printf ("A = % d, B = % d/N", a, B );
}
The output result of the above program is ______________________________.
4. Main ()
{Int A, B;
For (A = 1, B = 1; A <= 100; A ++)
{
If (B> = 20) break;
If (B % 3 = 1)
{
B + = 3; continue;
}
B-= 5;
}
Printf ("% d/N",)
}
The output result of the above program is ______________________________.
5. Main ()
{
Int A =-1; B = 4; K;
K = (++ A <0 )&&! (B -- <= 0 );
Printf ("% d/N", K, a, B );
}
The output result of the above program is ______________________________.
Three blank questions (1 ~ 10 blank, 1 point for each blank; 11 ~ 20 blank, 2 points for each blank, 30 points in total)
1. In C, if int data occupies 2 bytes, the long data occupies (1) _____ bytes,
Short data occupies (2) _______ bytes, float data occupies (3) ______ bytes,
Double Data occupies (4) _______ bytes, and char data occupies (5) _______ bytes.
2. the following definition is provided:
Int A = 12; respectively write the values of a after the following expression operation:
A. A + = A, the value of a is (6 )_________________.
B. A + = A-= A * = A, then the value of A is (7 )_________________.
3. If a string is set to "AB/NCD/X12", the length of the string is (8 )___________.
4. Rewrite the following expression to a valid expression in C language:
A. B * The b-4ac is rewritten to (9 )_________________.
B. (1/2) (ax-(A + x)/4A) is rewritten to (10 )________________.
5. The function of the following program is to enter scores of several students on the keyboard, calculate and output the highest scores.
And the lowest score,
End the input when a negative number is entered. Fill in the blanks.
Main ()
{
Float X, amax, Amin;
Scanf ("% F", & X );
Amax = X;
Amin = X;
While (11 )__________)
{
If (x> amax) amax = X;
If (12) __________) amin = X;
(13 )__________
} Printf ("/namax = % F/namin = % F/N", amax, Amin );
}
6. The following program segments require entering characters from the keyboard. If the letter is Y, the loop is stopped. Fill in the blanks.
Ch = '/0 ';
While (14) __________ CH = getchar ();
7. the approximate value of π can be obtained using the following formula:
π × π/6 ≈ 1/(1 × 1) + 1/(2 × 2) + 1/(3 × 3) + ...... + 1/(n × n)
If n is set to 10000, the value of the last item is about 1/10000, which is considered to be accurate.
Use the following program to obtain the approximate value of π. Fill in the blanks.
# Include <stdio. h>
# Include <math. h>
Main ()
{
Long I;
(15) __________ PI;
Pi = 0.0;
For (I = 1; I <= 10000; I ++)
PI + = (16 )__________;
Pi = SQRT (6.0 * PI);/* SQRT (): returns the square root function */
Printf ("Pi = % F/N", Pi );
}
8. The first two numbers in the Fibonacci series are 0 and 1. Each number starts from 3rd.
Equal to the sum of the first two numbers, that is:
0, 1, 2, 3, 5, 8, 13, 21 ,......
Evaluate the first 20 of the Fibonacci series. The number of outputs per row is required. Fill in the blanks.
# Include <stdio. h>
Main ()
{
Int F, F1, F2;
Printf ("Maid series:/N ");
F1 = 0; F2 = 1;
Printf ("% 6D % 6D", F1, F2 );
For (I = 3; I <= 20; (17 )__________)
{
F = (18 )__________;
Printf ("% 6D", F );
If (19) __________) printf ("/N ");
F1 = F2; F2 = (20 )__________;
}
Printf ("/N ");
}
Attached reference answer:
1. single choice.
01 ~ 10 a d a B C A c d
11 ~ 20 A c d a d B A C
21 ~ 30 c a B d A C
31 ~ 40 C B A D C A C
2. Write the running result of a program or program segment.
1. 1 2 3
2. 0.5
3. A = 2, B = 1
4. 8
5. 0 0 4
3. Fill in blank questions.
1. (1 )~ (5) 4 2 4 8 1
2. (6) 24
(7) 0
3. (8) 7
4. (9) B * B-4 * a * C
(10) (A * x + (a + x)/(4 * A)/2
5. (11) x> = 0
(12) x <Amin
(13) scanf ("% F", & X );
6. (14) (Ch! = 'Y ')
7. (15) float or double
(16) 1.0/(I * I)
8. (17) I ++
(18) F1 + F2
(19) I % 5 = 0
(20) f