Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Self-taught "C language programming" simulation test one
Self-taught "C language programming" simulation test one
Fill in the blanks

The basic data type in 1 and C languages is _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _.

2. In C language, the type descriptor of commonly used integer variables is _ _ _ _ _ _, which occupies _ _ _ bytes of memory, and the data range of signed commonly used integers is _ _ _ _ _.

3. The complement of the integer -35 in the machine is expressed as _ _ _ _ _.

4, execute the following statement int a = 8;; a+= a-= a * a; After that, the value of a is _ _ _ _ _.

5. There are the following statements: char a [] = {"I am a student"}; The length of the string is _ _ _ _, and a [3] = _ _ _ _ _

6. The difference between the symbol "a" and "a" is _ _ _ _.

7. The so-called "pointer" is _ _ _. The function of the "&"operator is _ _ _ _. The function of "*" operator is _ _ _ _.

8. There are the following input statements: scanf ("A =% d, b=%d, c=%d ",&; First, & ampb & amp;; c); In order to make the value of the variable A 1, the value of B 3 and the value of C 2, the correct form of data input from the keyboard should be _ _ _ _ _.

Second, multiple choice questions

1, let the integer variable a be 5, and the expression that makes b not be 2 is ().

A.b = a/2b . b = 6-(——a)c . b = a % 2d . b = a & gt; 3? 2: 1

2. In order to avoid the ambiguity of nested conditional branch statement if-else, C language stipulates that else in C program always forms a pairing relationship with ().

A. if b has the same indent position. If there is no pairing before.

C. there is no nearest if D before it. If we are on the same line,

3. The output of the following program is ().

int x= 10,y = 10;

printf("%d %d\n ",x——,——y);

A. 10 10 b . 9 9 c . 9 10d . 10 9

4. Let A be a one-dimensional array for storing (short) integers. If the first address of a is p, then the address of the i-th element in a is ().

A.P+I * 2b . P+(I- 1)* 2c . P+(I- 1)d . P+I

5, choose the following identifier is illegal ().

A.hot_do B. cat 1 C. _pri D. 2ab

6, the output of the following program is ().

int a = 5;

float x = 3. 14;

a* = x *(E '-' A ');

printf("%f\n ",(float)a);

A.62.000000 b 62.800000 c 63.000000d 62

7. Set the description double (* p1) [n]; Where the identifier p 1 is ().

A. n pointers to two variables.

B. Function pointers to n bivariate variables.

C. a pointer to a one-dimensional array of n double-precision elements.

D. One-dimensional pointer array with n pointer elements, each pointer element can only point to a double precision quantity.

8. There are the following statements in the C program: char *func(int x, int y); It is ().

A. definition of function func B. calling function func.

C. prototype description of function func. D. illegal.

9, the output of the following program is ().

Char str[ 15]= "Hello!" ;

printf("%d\n ",strlen(str));

A. 15 B. 14 C. 7 D. 6

10, analysis of the following program output results is ().

Master ()

{int a=5,b=- 1,c;

C = addition (a, b);

printf("%d ",c);

C = addition (a, b);

printf("%d\n ",c); }

Int addition (int x, int y)

{static int m=0,n = 3;

n * = ++ m;

m = n % x+y++;

Return (m); }

A.2,3 B,2 C,3,2 D,2,4

1 1, the following description is incorrect ().

Strings can be stored in character arrays.

B. you can input and output character arrays as a whole.

C. integer arrays can be input and output as a whole.

D. You cannot assign a character array as a whole through the assignment operator "=" in the assignment statement.

12, the output of the following program is ().

# Define f(x) x*x

Master ()

{int a=6,b=2,c;

c = f(a)/f(b);

printf("%d\n ",c);

}

A.9 B. 6 C. 36 D. 18

13 has the following definitions: int x= 10, y=3, z;

Statement printf ("%d \ n ",z=(x%y, x/y)); The output of is ().

A. 1 B

14. Define the following variables and arrays: int I;; ; int x[3][3]={ 1,2,3,4,5,6,7,8,9 };

Then the statement for(I = 0;; I<3; i++) printf("%d ",x[I][2-I]); The output of is ().

A. 1 5 9 B. 1 4 7 C. 3 5 7 D. 3 6 9

15, the following two-dimensional array a is initialized correctly ().

A.int a[2][3]={{ 1,2},{3,4},{5,6 } }; B. int a[ ][3]={ 1,2,3,4,5,6 };

C.int a[2][ ]={ 1,2,3,4,5,6 }; D. int a[2][ ]={{ 1,2},{3,4 } };

16. Run the following program twice. If you input 6 and 3 from the keyboard respectively, the output result is ().

int x;

scanf("%d ",& ampx);

if(x++ & gt; 5) printf("%d ",x);

else printf("%d\n ",x--);

A.7 and 5 B. 6 and 3 C. 7 and 4 D. 6 and 4.

17 has the following definitions: char * aa [2] = {"ABCD ","ABCD "};; Then the following statement is correct ().

A) A) The values of AA number components are "abcd" and "ABCD" respectively.

B)aa is a pointer variable that points to a one-dimensional character array containing two array elements.

C) c) Two elements of AA array respectively store the first address of a one-dimensional character array containing four characters.

D) The addresses of the characters "a" and "a" are stored in two elements of D)aa array.

18, the output of the following program is ().

char *p 1="abcd ",*p2="ABCD ",str[50]= " XYZ ";

strcpy(str+2,strcat(p 1+2,p2+ 1));

printf("%s ",str);

A.xyabcAB b . ABC abz c . ABabcz d . xycdBCD

19, the output of the following program is ().

int a[5]={2,4,6,8, 10},*P,* * k;

p = a; k = & ampp;

printf(" % d " ,*(p++));

printf("%d\n ",* * k);

A.4 4 B. 2 2 C. 2 4 D. 4 6

20. You can't put the string: Hello! The statement assigned to array b is ().

A.char b[ 10]={'H ',' e ',' l ',' l ',' o ','!' };

B.char b[ 10]; B= "Hello!" ;

C.char b[ 10]; Strcpy(b, "Hello!" );

D.char b[ 10]= "Hello!" ;

Third, the reading procedure.

1, floating-point number f = 3.1415927;

printf("%f,%5.4f,%3.3f ",f,f,f);

The output of the program is.

2、int x=6,y = 7;

printf("%d ",x++);

printf("%d\n ",++ y);

The output of the program is.

3、a = 3;

a+=(a & lt; 1)? A:1;

printf("%d ",a);

The result is.

4、for (a= 1,b = 1; a & lt= 100; a++)

{ if(b & gt; =20) broken;

if(b%3== 1)

{ b+ = 3; Continue; }

b-= 5; }

The value of the program output result a is.

5、int y= 1,x,*p,a[ ]={2,4,6,8, 10 };

p = & ampa[ 1];

for(x = 0; x & lt3; x++)

y+= *(p+x);

printf("%d\n ",y);

The value of the program output result y is.

Fourth, fill in the blanks by procedures.

1. Enter the number 10 from the keyboard and find its average value.

Master ()

{ int I;

float f,sum

For(i= 1, sum = 0.0 I< 1 1; i++)

{ ;

; }

printf("average=%f\n ",sum/ 10); }

2. The following procedure is to create a file named myfile, store the characters input from the keyboard in the file, and close the file when the keyboard input is completed.

# Including

Master ()

{ FILE * fp

char c;

FP =;

Do {

c = getchar();

fputs(c,FP);

}while(c! = EOF);

}

3. The function of the following program is to input the scores of several students from the keyboard, count and output the scores and the lowest scores, and end the input when a negative number is entered. Please fill in the blanks.

Master ()

{ float x,amax,amin

scanf("%f ",& ampx);

amax = x; Amin = x;

while()

{ if(x & gt; amax)amax = x;

if()Amin = x;

scanf("%f ",& ampx); }

Printf(" \ namax =%f\namin =% f \ n ",amax, Amin); }

V. Programming problems

1. Keyboard input three integers A, B and C, and output one of them.

2. Output all leap years from 1900 to 2000. Change one line every three years. (The conditions for judging leap years are one of the following: divisible by 4, but not by 100. Or divisible by 400. )

3. Please fill in a function int fun(int a). The function is to judge whether A is a prime number. If A is a prime number, return1; If it is not a prime number, the value is 0. The main function reads one from the keyboard.

4. There are n students, and each student's information includes student number, gender, name, and scores of four courses. Input the information of n students from the keyboard, and output the information of students with total average score, including student number, gender, name and average score.