I. Multiple choice questions
1 C language programs always start with.
A) the first executable statement in the program
The first function in the program
C) main functions
D) Include the first function in the file.
Analysis: In a C language source program, whether the main function is written before or after the program, the execution of the program always starts from the main function and ends with the main function.
The correct answer to this question is C.
2. The following statement is correct.
A) C programming, regardless of uppercase and lowercase letters.
B) When writing a C program, only one statement can be written in one line.
C) When writing a C program, you can write several lines in a statement.
D) When writing a C program, each line must have a line number.
Analysis: C language strictly distinguishes uppercase and lowercase letters, such as "A 1" and "a 1", which are considered as two different identifiers. C program is very flexible, which can be one line with multiple sentences and one line with no line number.
The correct answer to this question is C.
3. The following description of the characteristics of C language is incorrect.
A) C language has the dual characteristics of high-level language and low-level language, and its execution efficiency is high.
B) C language can be used to write both application programs and system software.
C) The portability of C language is poor.
C language is a structured modular programming language.
Analysis: C language is a language between assembly language and high-level language. With direct access to physical addresses and operating hardware, C language can not only write application programs, but also develop system software. Moreover, C program is more portable, clear and modular than assembly language.
The correct answer to this question is C.
4. The minimum unit of C language source program is.
A) program line b) statement c) function d) character
Analysis: program lines, statements and functions are all composed of characters, and characters are the smallest unit of C language.
The correct answer to this question is D.
5. Among the following four items, the keyword belonging to C language is.
A) character b) definition c) unsigned d) return
Analysis: C language has 32 keywords (or reserved words), all of which have specific meanings and are composed of lowercase letters, so option A is wrong, option B is not a reserved word, and option D is a spelling mistake of return.
The correct answer to this question is C.
6. Decimal number 2403 is converted into hexadecimal number.
A) 963 B) 369 C) 953 D) 359
Analysis: The method of converting decimal number into hexadecimal number is: divide by 16 until quotient 0, and take the remainder backwards.
The correct answer to this question is a.
7. Binary number 0011010/is converted into octal number.
A) 055 B) 065 C) 056 D) 152
Analysis: The method of converting binary numbers into octal numbers is: divide from right to left, and write every 3-bit binary number as 1 bit octal number.
The correct answer to this question is B.
8. Converting the binary number1011.01into a decimal number is.
a)9 1.75 B)9 1.375 C)9 1. 125D)9 1.25
Analysis: the way to convert binary numbers into decimal numbers is to multiply each number by its weight and then add it up. The integer part of the problem is: (10111) 2 =1× 26+1× 24+1× 23+ The fractional part is: (0.011) 2 = 0× 2-1× 2-2+/kloc-0 /× 2-3 = 0.25+0.125 = 0.375.
The correct answer to this question is B.
9. The numbers used in the internal operation of the computer are.
A) decimal number b) hexadecimal number c) binary number d) octal number
Analysis: In real life, we can't find physical components with ten stable states, but components with two stable states can be found everywhere. For example, a switch has two stable states: power-on and power-off. Components inside the computer use "1" for power-on and "0" for power-off, so the numbers used for internal operation of the computer are all binary numbers. As for octal numbers and hexadecimal numbers, they are artificial abbreviations of binary numbers.
The correct answer to this question is C.
10. The number of binary digits in a word is.
A) 2 bytes, that is, 16 bits B) 3 bytes, that is, 24 bits C) 4 bytes, that is, 32 bits d) varies with different computer systems.
Analysis: 1 binary bit is also called 1 bit, and 8 binary bits are called 1 BYTE, that is, there is a fixed conversion relationship between bytes and bits, but there is no fixed conversion relationship between word length and byte byte in computer, and word length varies with CPU model.
The correct answer to this question is D.
1 1. In the C language system, assuming that the data of type int takes up 2 bytes, how many bytes does the data of type double, long, unsigned int and char take up?
A) 8,2,4, 1 B) 2,8,4, 1 C) 4,2,8, 1 D)
Analysis: From the above questions, we can see that the word length of CPU determines how many bytes are allocated to various variables. When the type of int accounts for 2 bytes, the bytes of double, long, unsigned int and char account for 8, 4, 2 and 1 byte respectively.
The correct answer to this question is D.
12. The execution result of the following program segment is.
int i=5,k;
k =(++ I)+(++ I)+(i++);
printf("%d,%d ",k,I);
a)24.8 B)2 1.8 C)2 1.7D)24.7
Analysis: In the expression k=(++i)+(++i)+(i++), I is preceded by two "++"signs, so before calculating K, I should be increased twice, that is, I will become 7, and then three 7s will become K 2 1, and the "++"sign in the expression is followed by I.
The correct answer to this question is B.
13. The execution result of the following program segment is.
int I = 5;
printf("%d,%d,%d ",I,(++i)+(++i)+(i++),I);
A) 8,20,5 B) 8,2 1,5 C) 5,20,8 D) 5,2 1,8
Analysis: This question can't be regarded as substituting k=(++i)+(++i)+(i++) in the 12 question into the printf function, because the order in which the function processes parameters is from right to left, so the value of the expression (++i)+(i++) is no longer 7+7.
The correct answer to this question is a.
14. The output of the following program segment is.
int i = 32769
printf("%d\\n ",I);
A) 32769 B) 32767 C) -32767 D) The output is not a definite number.
Analysis: int variable indicates that the data range is -32768~+32767, and when assigned, it is less than -32768 or greater than +32767, and overflow will occur. The stored value after overflow is: minus the modulus of 65536 for positive overflow and plus the modulus of 65536 for negative overflow, so the output of this question is 32769-.
The correct answer to this question is C.
15. The output of the following program is.
Master ()
{ int a =-32769;
ptintf("%8U\\n ",a);
}
A) 32769 B) %8U C) 32767 D) -32767
Analysis: Format characters must be lowercase. "%8U" in the title will not be used as a format controller, but will be output as it is. Variable A will have no corresponding format description and will not be sent.
The correct answer to this question is B.
Second, fill in the blanks
1. If the output of the following program is 13, please fill in the blanks.
Master ()
{ int x = 0 16;
printf("%d\\n ", 1); }
Analysis: In C language, the number starting with 0 is octal, and 0 16 is equivalent to decimal number 14. When the printf statement is executed, the output item should be x minus 1.
The correct answer to this question is 1-x or x-= 1.
2. The output of the following program segment is 2.
int k = 10;
float a=3.5,b=6.7,c;
c = a+k % 3 *(int)(a+b)% 2/4;
Analysis: This question examines the concept of priority of operators. In the formula, the value of (a+b) should be calculated first, and then the forced type conversion should be calculated. *,/and% are first-class, and should be calculated from left to right, and finally addition and assignment.
The correct answer to this question is 2 3.5 million.
3. If the output after executing the following program segment is: 3, 4, 5, please fill in the blanks.
int a,b=3,c = 5;
a = b & ltc? 3:c++;
printf("%d,%d,%d ",a,b,c);
Analysis: This topic examines the concepts of conditional operators and incremental operators, in which B.
The correct answer to this question is 3 b++.
4. In C language, the lowest priority of operators is 4.
Analysis: Compared with other high-level languages, assignment number is not the lowest priority in C language, and comma operator is the lowest priority operator in C language.
The correct answer to this question is the 4 comma operator.
5. If the output of the following program is 4, please fill in the blanks.
Master ()
{ int i,j,k;
k = 0; I = j =-2;
k+=-I-5;
printf("%d\\n ",k);
}
When three plus signs or three minus signs are connected together in C language, the symbol in the middle belongs to the variable on the left, that is, -i-j is equivalent to-(i-)-j.
The correct answer to this question is 5-J. <; /c? 3:c++;
Test 2
I. Multiple choice questions
1. The following statement is incorrect.
A) there must be a semicolon at the end of the c statement.
B) Both integers and real numbers can be accurately expressed in C language.
C) Operator "%"can only be used for integer operations.
D) Multiplication and division operators have higher priority than addition and subtraction operators.
2. The following statement is correct.
A) the c statement must be preceded by a line number.
B) Only one statement can be written per line in C program.
C) C language itself has no input and output statements.
D) Comments must be followed by a line of statements.
3. Compound statements should be enclosed.
A) curly braces b) square brackets c) curly braces d) angle brackets
4. Converting binary number101111into hexadecimal number is.
A) 5557 B) B6F C) 7555 D) F6B
5. Converting decimal number 0.625 into binary number is.
a)0. 1 1 1 B)0. 10 1 C)0.5d)0。 A
6. If you can't write a line in C language, you can.
A) break a line with a comma b) break a line with a semicolon c) break a line with a carriage return d) break a line in any space.
7.c language allows a statement to write two lines, and the following statement is incorrect.
A) int a,B) int a C) int D) int a,B
b; ,b; Party A and Party B; ;
8. The output of the following program is. ("□" indicates a space)
int a = 3366
printf("|%-08d| ",a);
A) |-0003366 | b) | 00003366 | c) | 3366 □□□□□□| d) The output format is illegal.
9. If there is a statement: int a;; Floating b; The following input statement is correct.
A) scanf("%f%f ",& i, & b);
B) scanf("%f%d ",& 1, & b);
C) scanf("%d, %f ",& 1, & b);
D) scanf("%6.2f%6.2f ",& i, & b);
10. The output of the following program is.
Master ()
{ int x= 1 1,y = 1 1;
printf("%d%d\\n ",x -,-y);
}
A) 1 1, 1 1 B) 10, 10 C) 10, 1 1 D) 1 1
1 1. Converting octal number 307 into binary number is.
a) 100 1 100 1 1 B) 1 1000 1 1 1 C) 1 10000 1 165438
12. When executing the following program segment and assigning values to x and y, what cannot be used as a data delimiter is.
int x,y;
scanf("%d%d ",& ampx & amp; y);
A) space B) Tab key c) carriage return d) comma
13. The following legal statement is.
A) int a=8,b;
b = ++ a++;
printf("%d,%d ",a,b++);
b)int a;
printf("\\"%d\\ " ",scanf("%d ",& ampa));
c)char a;
scanf("%c ",& ampa);
char b=scanf("b=%c ",& ampb);
d)char c = getchar();
putchar((int)c);
14. When executing the following program, to assign 25 and 2.5 to A and B respectively, the correct input method is.
int a;
Floating b;
Scanf("a=%d, b=%f ",& i, & b);
A) 25□2.5
25,2.5
C) a=25,b=5.5
D) a=25□b=2.5
15. and the mathematical formula a? b x? Y is not equivalent.
A) a*b/x*y
B) a*b/x/y
C) a*b/(x*y)
D) a/(x*y)*b
Second, fill in the blanks
1. The value of the expression 5%(-3) is 1, and the value of the expression -5%(-3) is 2.
2. In C language, the format input library function is 3 and the format output library function is 4.
3. The output of the following program is 5.
int x =-32769;
printf("%d ",x);
4. The output of the following program is 6.
Master ()
{
float a= 1,b;
b = ++ a * ++ a;
printf("%f\\n ",b);
}
5. The output of the following program is 7.
Master ()
{
int x=5,y;
y = ++ x * ++ x;
printf("y=%d\\n ",y);
}
Take the exam and answer questions.
I. Multiple choice questions (1) b (2) c (3) c (4) b (5) b (6) d (7) d (8) c (9) c (10) d (1/kloc-)
II. Fill in the blanks 122-23 Scan 4 Print 5 32767 66 007 49
Test 3
I. Multiple choice questions
1. The following data types that do not belong to C language are.
A) integer type b) real number type c) logic type d) double precision real number type
Analysis: Compared with other high-level languages, C language has neither logical data nor logical variables.
The correct answer to this question is C.
2. In C language, the following are structural types.
A) integer type b) real type c) pointer type d) structural type
Analysis: There are three types of structured data in C language: array, structure and * * * object. An array is a collection of data of the same type, and a structure is a collection of data of different types.
The correct answer to this question is D.
3. The following string does not meet the requirements of the identifier.
A) sum b) sum C) 3cd D) end
Analysis: Identifiers can only consist of 26 English letters (uppercase and lowercase), numbers 0~9 and underscores, and cannot start with numbers. The 3cd in the title does not meet the requirements.
The correct answer to this question is C.
4. The following can correctly represent octal numbers.
a)0x 16 B)029 C)- 1 14D)033
Analysis: Option a) starts with 0x as a hexadecimal number, option b) starts with 0, but the number 9 appears, and option c) is a decimal number.
The correct answer to this question is D.
5. Among the following four options, the option that is a legal real number is.
A) 2e-4.2 B)-0.50 C) 0.2e-.5 D)-e5
Analysis: There are two representations of real numbers: decimal form and exponential form. Decimal form, must have a decimal point; In exponential form, the letter E must be preceded by a number and followed by an integer. "2e-4.2" in option A, "0.2e-.5" in option C and "-e5" in option D are all illegal.
The correct answer to this question is B.
6. In C language, the storage form of character data in memory is.
A) original code b) complement c) complement D) ASCII code
Parsing: In C language, int data is stored in the form of complement, and character data is stored in the form of ASCII code.
The correct answer to this question is D.
7. The following are the correct character constants.
a)" a " B)′\ \ \ \′C)" \ \ r " D)277
Parsing: Character constants are defined as characters enclosed in single quotation marks. The separators of A and C are wrong, D is beyond the representation range of char data, and' \ \' is an escape character.
The correct answer to this question is B.
8. If there is a statement charch1=' \ \ x 41'; Ch 1。
A) contains 4 characters b) contains 3 characters c) contains 2 characters d) contains 1 character.
"4 1" in parsing "\\x4 1" is a hexadecimal number, that is, 65 in decimal, and 65 stored in ch 1 is the ASCII code of the letter "a".
The correct answer to this question is D.
9. The length of the string output by the following program segment is.
printf(" \ \ \ \ AAA \ \′CCC \ \ bddd \ \ " ");
a) 1 1 B) 12 C) 13D) 17
Parsing: \ \, \', \\b and \ "are escape characters, and the program output result is: \ \ aaa 'ccddd".
The correct answer to this question is a.
10. In the following operators, the operand is required to be an integer.
A) / B) * C) % D)!
Analysis: "/","*", "!" The operand of can be an integer or a real number. Only the remainder operator'%' requires that the operand must be an integer.
The correct answer to this question is C.
1 1. The following legal transfer statement is.
a)x+y = 2002; B) ch= "green"; c)x =(a+b)++; d)x = y = 03 16;
Resolution: the left end of assignment number cannot be an expression, and option a) is wrong; The assignment number cannot assign a string to a variable, and option b) is also wrong; Incremental operator "++"cannot be used for expressions, option c) is wrong.
The correct answer to this question is D.
12. Assuming that A is an int type, B is a double type, C is a float type and D is a char type, the result type of the expression a+b*c-d/a is.
A) int type B) float type C) double type D) char type
Analysis: The conversion rule of mixed operation of different types of data is that before the operation, float data will be automatically converted into double type and char data will be automatically converted into int type. In the process of operation, int data and double data should be converted into the same type, that is, double type, and the operation result is also double type.
The correct answer to this question is C.
13. The output after executing the following program segment is.
int x = 0xcde
printf("M,%4o,%4x\\n ",x,x,x);
A) 3294,6336,cde B) 3294,6336,xcde C) 3294,06336,0xcde D) 3294,6336,0cde
Analysis: 0xcde is a hexadecimal number written as a binary number:11001011165438. When sent in octal, it is written as a three-digit binary number from right to left.
The correct answer to this question is a.
14. The output of the following program is.
# Including
# Including
Master ()
{ int a,b;
Floating c;
b = 5; c = 6; c = b+ 7; b = c+ 1;
a = sqrt((double)b+ c);
printf("%d,%f,%d ",a+6,c,b);
}
A) 1 1.000000, 12.000000, 13.000000
B) 1 1.000000, 12.000000, 13
C) 1 1.000000, 12, 13
D) 1 1, 12.000000, 13
Parsing: C language allows one type of data to be assigned to another type of variable, but the type of variable will not change because of the assignment. For example, in this question, b+7 means 12 is assigned to the floating-point variable c, and the value of c should be/kloc-0 12.0000000 instead of an integer 12. Similarly, A = sqrt ((double) B+C+c.
The correct answer to this question is D.
The value of 15.x is.
Unsigned int x = 65535
printf("%d\\n ",x);
A) 65535 B) 1 C) Error D)-1
Analysis: X is defined as an unsigned integer in the question, and has been initialized to:111111/65438. Then take the highest bit of 1 as the symbol,111111/65438+.
The correct answer to this question is D.
Second, fill in the blanks
1. The function of the following program segment is to output the ASCII code of lowercase letters corresponding to uppercase letters. Please fill in the blanks.
char ch
scanf("%c ",& ampch);
ch =(ch & gt; =′A′& amp; & ampch & lt=′Z′)? ( 1):ch
printf("2\\n ",ch);
Analysis: the conditional operation in the topic is to judge whether the input letters are capitalized, when ch> =' a'&; & ampch & lt When ='Z' is true, to convert it into corresponding lowercase letters, add 32 to the ASCII code value. The known topic means to output the ASCII value of lowercase letters corresponding to uppercase letters, so the output format in printf statement should be decimal format.
The correct answer to this question is1ch+32,2% d.
2. The execution result of the following program segment is x = 3 and y = 4.
inta=3,b=5,x,y;
x=a+ 1,b+6;
y=(a+ 1,b+6);
printf("x=%d,y=%d ",x,y);
Analysis: This question examines the concept of comma expression. Because the comma operator has lower priority than the assignment number, when X = a+ 1 and B+6 are executed, X gets the value of a+ 1.
The correct answer to this question is 344 1 1.
3. After performing the following procedure, the value of k is 5.
int a= 1,b=2,c=3,d=4,k;
k = a & gtb? A: c>d? C: D.
Analysis: if the value of a>b is false, solve the expression k = a >;; b? A: c>d? C:d is equivalent to finding k = a>b? A: (c>d? C: D).
The correct answer to this question is 5 4.
4. Inta = 5 is known; Then execute a+= a-= a * a; In the statement, the value of a is 6.
Analysis: The operation sequence of a+=a-=a*a is from right to left, which is equivalent to finding a+=(a-=a*a), in which the operation in brackets gets a=5-5*5, which means a=-20. The next step is to find a+=a, which means a=a+a, and substitute -20.
The correct answer to this question is 6 -40.
5. The running result of the following program is x = 7 and y = 8.
Master ()
{ float x = 4.9int y;
y =(int)x;
printf("x=%f,y=%d ",x,y); }
Analysis: Forced type conversion does not change the initial value of X, and X is still 4.9, but the conversion results in an intermediate result. In this question, the intermediate result is assigned to y, and the decimal part is discarded without rounding.
The correct answer to this question is 74.9884.
Test 4
I. Multiple choice questions
1. For the expression type in the if statement, the following is the correct description.
A) Must be a relational expression.
B) It must be a relational expression or a logical expression.
C) Must be a relational expression or an arithmetic expression.
D) can be any expression.
Analysis: The expression of if statement in C language can be of any type, as long as the value of the expression is not 0, it is true and 0 is false.
The correct answer to this question is D.
2. When multiple if_else statements are nested, the if method matching else is.
A) if they have the same indented position.
B) the nearest if on it.
C) the nearest if is lower than
D) if on the peer.
Analysis: When multiple if_else are nested, else always appears in pairs with the nearest if above it.
The correct answer to this question is B.
3. The if statement of the following error is.
A) if (x & gty)z = x;;
B) if (x = = y)z = 0;;
C) if(x! =y) printf("%d ",x) else printf("%d ",y);
D) if (x
Parsing: The first printf statement in option c) is wrong because a semicolon is missing after it.
The correct answer to this question is C.
4. The following is the correct way to judge the equality of two strings.
A) if (str 1=str2)
B) if (str 1==str2)
C) if(strcpy(str 1,str2)=0)
D) if(strcmp(str 1,str2)==0)
Analysis: the assignment number is used in option a), which is obviously wrong. The string copy function strcpy in option c) cannot compare sizes, and the "= =" sign in option b) has no string comparison function. The string comparison function is used to compare the sizes of two strings.
The correct answer to this question is D.
5. The correct result of performing the following procedure is.
Master ()
{ float a = 1.9;
Switch (a)
{ case 0:printf(" 0000 ");
Case1:printf ("111");
Case 2: printf ("2222");
}
printf("%f ",a);
}
A) 1.900000
b) 1 1 1 1222 1.900000
C) 2222 1.900000
d)0000 1 1 1 12222 1.900000
Analysis: The single-precision real number A is defined in the question, so the output of the bottom printf statement has 6 decimal places. In addition, when judging the value of switch expression, C language treats it as integer data (but does not divide 4 by 5), so the program starts with case 1, and since there is no break statement, case 2 is executed next.
The correct answer to this question is B.
6. The output of the following program is.
Master ()
{ int a=20,b=30,c = 40
If (a & gtb) a=b,
b = c; c = a;
printf("a=%d,b=%d,c=%d ",a,b,c);
I hope it helps you! ! ! I also hope to get some points! ! ! thank you