当前位置:网站首页>College C language final exam · multiple choice questions · summary notes of mistakes and difficulties

College C language final exam · multiple choice questions · summary notes of mistakes and difficulties

2022-06-26 04:00:00 Box bridge

This is my wrong question , Then sum up the wrong knowledge points , Each set of questions has a number segment

First set of questions

1、% Binary operator , Left binding , Both left and right are integers , Cannot be double

2、 Array 【0】 The first and 【4】 The fifth one ,

3、 character 0 by NULL

4、 Precautions when defining structure variables typedef,struct

5、0 The beginning octal cannot have 8、0x Start with hex 、 Hexadecimal has abcdef

6、e Said to 10 The idempotent of the base , Must be an integer ,e There should be numbers at the front and back

7、 identifier : Letter 、 Underline 、 Digital composition ,,, Keywords cannot be , Can 't start with a number

8、pow( base number , Power number ),abs() Integer absolute value ,fabs() Floating point absolute value ,exp(e Of n Power )

9、getchar() Read a number one by one

10、 The logical operator can be any legal expression

11、x It is greater than 1 The odd number x%2 == 0 error

12、while(a–); Last a==-1. The grass is wrong but while I haven't received

13、void (*pf)() Pointer function ,void *pf() The return value is a pointer variable

14、char *s; s=“BOOK!”

15、 character string ’\0’ Not counting the character length

16、\,\n The conversion character in the string , Count one character each

17、 Automatic variable auto, Not automatically assigned determine Initial value of .

18、 Static variables satic, The initial value will not be assigned every time .

19、 Angle sign of array variable

20、 Pass a value to the address of a pointer variable , The original value does not change .

21、 Calculation in macro definition #define f(x) xx quote f(a+1) = a+1a+1a+1 = 3a+1;f((a+1))=44*4=64

The second set of questions

1、 Formal and actual parameters of structure variables , Value transmission and address transmission are different .

6、 Octal number 0 Start with and cannot contain numbers 8

7、 Equal sign = Right knot and sex , You cannot assign a number to an expression .

8、a=(b=4)+(c=6),, have to a = 10;+ first =

9、 The input data format must be the same as scanf() The format control strings in the match exactly scanf("%d;%d",&a,&b); Input required 3;5

10、#define The defined formula directly calculates #define M N+1 #define N 5 #define f(x) (xM) == xN+1

11、feof(fp) If you read to the end of the file ,eof Function value is 0 value , Otherwise 0

12、 Prime numbers can only be 1 Or the number divided by itself

The third set of questions

1、 Symbolic Constant refers to the constant represented by a symbolic name through macro definition in the program #define

2、if When the condition is logic and expression ,&& If the first is false, the second expression will not be judged ( Short circuit principle )

3、switch The statement did not break It runs all the time

4、 Macro definitions make simple substitutions

5、10^5=15 Exclusive or operation , Different at the same time 1

6、 Software design is divided into high cohesion and low coupling 、 The module size and scale are appropriate 、 The dependencies of the modules are appropriate

7、 Constants do not belong to identifiers

Fourth set of questions

1、 Real constant ( Floating point numbers ) There is only one decimal system

2、&& and || Short circuit of logic expression , After the previous expression evaluates , The latter expression may not be calculated

3、#include The command line can appear in the middle of the program file

4、++P->a The effect is that members a increase 1

5、switch Statement has no semicolon

6、#define The statement also has no semicolon

7、 Pointer to string ,sizeof(b) = 4, Four bytes

8、 Pointer variable name -> Member name ,(* Pointer variable name ). Member name ,

The fifth set of questions

1、 Row coordinates cannot be omitted when defining a two-dimensional array

2、 Character arrays cannot be assigned directly mark=“abc”, It seems that the pointer can

3、 When the pointer points to the first address of an array , You can use p[3] Use

4、*p++ Same operation priority , Right to left , Present address +1 Then take the content

5、 The comma operator , Take the last value (a+b,b+3)

6、 Do not use the address character when entering the array name &

7、 Short circuit principle ,a=b=c=d=m=n=2;(m=a>b)&&(n=c>d)

8、 To define an array int a[2][]={ {1,2},{3,4}} error int d[3][2]={ {1,2,1},{1,2,3},{1,2,3}} The error exceeds the limit

9、 The second of the array definitions [] Cannot omit , If omitted, you will not know how many columns there are , Infinite columns overflow

10、 From the main Start to... Of this procedure main End of the function

Sixth set of questions

1、strcmp(s,t) Compare s>t Return greater than 0 Number of numbers

2、int a=5,b=4,c=3; d =(a>b>c) The result is 0,,, Because first run a>b The result is 1, then 1>c For false

3、for(i=9;i>=0;i–) a[i] = 10 - i; Be careful a[i] Also from the 9 At the beginning

4、a[10]= {10,9,8,7,6,5,4,3}; sum(&a[2]); a[0]=a[1]+a[2]; The result is a[2] = a[3]+a[4]

5、int x=1,y=1; (!x||y–) The value of is 1, He is or

The eighth set of questions

1、 It can be expressed correctly a and b A logical expression that is both positive and negative a*b>0

2、printf("%s,%8s,%8.3s",“china”,“china”,“china”) china,000china,00000chi

3、 Functions cannot be nested

4、strcmp()
(1)strcmp Is to compare the size of two strings , Returns... When two strings are the same 0, Returns a positive value when the first string is greater than the second string , Otherwise, a negative value is returned .
(2) The algorithm for comparing two strings is : Compare the corresponding characters in two strings one by one , The character size is in accordance with ASCII Code value determination , Compare from left to right , If you encounter different characters , The size relationship of the first pair of different characters determines the size relationship of the two strings , If no different characters are encountered and a string ends first , So this string is smaller , Otherwise, the two strings are equal .

5、 C Language parameter list a[ ] What does that mean? , How to use it? ?
Represents a pointer , The array name is actually a pointer to the first element of the array , When actually calling, just pass the array name as an argument to the formal parameter of the function

6、 If it's an expression, it must have a number —— Assignment expression : The expression value is the leftmost value ,a=b=5, The expression is 5, Constant cannot be assigned ,printf("%d",a=5+9) Output 14

7、&& and || Short circuit phenomenon of , priority ! > && > ||

8、018 The value of is illegal , Octal is not 8 Of

9、% Both sides of the symbol are required to be integers , It's not a whole number

10、%ld yes long int Format output

additional :

1、do-while Behind a ; A semicolon

2、!= Number is higher than = while(c=getchar()!=’/n’) and while((c=getchar())!=’/n’) difference , Input ab I will be the first c=1, The second is ab

3、*p++ and (p)++ The difference between , The first is p Address to add 1 Then the value is taken , The second is after the value , It's worth adding 1,++ Has a higher priority than

4、 Array name : Represents the address of the first element , Array name cannot be added by itself , He is the address constant name , if a[10] As long as there is a++,a=a+2 That is wrong

5、a+1=&a[1]

6、 int a[]={1,2} legal ,int a[][4]={2,4,5} legal int a[4][]={2,3,4} illegal , The second one in two dimensions is the column

Then there are a few easy and slightly difficult questions :

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

 Insert picture description here

原网站

版权声明
本文为[Box bridge]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202180544594346.html