当前位置:凯发k8一触即发首页 » 会计类答案 » 正文

629 人参与  2023-06-12 23:17:08  分类 :会计类答案
chapter 1 introducing c-2

quiz 1 introducing c

1、when compile a c program, the comments will .
    a、be compiled and appear in the object code.
    b、be compiled, but not appear in the object code.
    c、not be compiled and not appear in the object code.
    d、not be compiled, but appear in the object code

2、a file written by c language .
    a、can be executed immediately.
    b、is a source program.
    c、can be executed after compilation.
    d、can be executed after compilation and interpretation.

3、many programming languages borrow heavily form c language, including c , c# .

4、one of c’s advantages is efficiency. because c was intended for applications where assembly language had traditionally been used, it was crucial that c programs could run quickly and in limited amounts of memory.

5、c’s weaknesses arise from the same source as many of its strengths: c’s closeness to the machine.

chapter 2 data types and expression -2

quiz 2 datatype, variable and constant

1、which of the following is a legal c identifier?
    a、1stunpu
    b、stu@npu
    c、stu-npu
    d、_stu_npu

2、which of the following is not keyword in c language?
    a、do
    b、int
    c、void
    d、main

3、which of the following is not a constant in c language?
    a、012
    b、"a"
    c、'\n'
    d、'ab'

4、which of the following is not a float constant in c language?
    a、2.38
    b、.23
    c、1.2e-2
    d、e-2

5、the three identifiers, weight, weight and weight, are not equal in c language.

chapter 2 data types and expression -3

quzi 3 operators and expression

1、in c language, which of the following operator requires its operands must be of type int?
    a、/
    b、*
    c、=
    d、%

2、of which operation the precedence is higher than others’?
    a、
    b、%
    c、*
    d、()

3、the value of the expression 3.6-5/2 1.2 5%2 is ____.
    a、4.3
    b、4.8
    c、3.3
    d、3.8

4、suppose all variables in the following expressions have been declared and initialized, which of the following is not a legal expression in c language?
    a、a = (2, b= c 2)
    b、(int)18.5%3
    c、a = b = c b
    d、a := b 1

5、if an expression is the sum of four data of different types, including int, long, double and char, the expression’s type is ____.
    a、int
    b、long
    c、char
    d、double

6、the expressions i and i are exactly not the same as (i = 1).

chapter 3 program control structure -2

quiz 4 formatted input & output

1、if c is a variable of type char, which one of the following statements is illegal?
    a、i = c; /*i has type int*/
    b、c = 2*c – 1;
    c、putchar(c);
    d、printf(c);

2、suppose that we call scanf as follows: scanf(“%d%f%d”, &i, &x, &j); if the user enters: 10.8 9 3↙ what will be the values of i, x, and j after the call? (assume that i and j are int variables and x is a float variable. ↙ is used to represent enter key)
    a、10 9 3
    b、11 9 3
    c、10.8 9 3
    d、10 0.8 9

3、suppose that we call scanf as follows: scanf(“%f%d%f”, &x, &i, &y); if the user enters: 12.3 45.6 789 what will be the values of x, i, and y after the call? (assume that x and y are float variables and i is an int variable. ↙ is used to represent enter key)
    a、12.3 45 789
    b、12.3 45.6 789
    c、12 45 789
    d、12.3 45 0.6

4、which one of the following is correct?
    a、the output item must be given when calling function printf.
    b、when calling function getchar to read in a character, we can input its corresponding ascii code.
    c、in c language, integers can be output in various forms, e.g. decimal, binary, octal and hexadecimal.
    d、the header file stdio.h must be included before calling function putchar.

5、assuming the following statements: char c1='1',c2='2'; c1=getchar(); c2=getchar(); putchar(c1); putchar(c2); if input a└┘↙ when run the code, ↙ is used to represent enter key, └┘ is used to represent space, which one of the following statements is correct?
    a、the program will wait for the second character input by user.
    b、variable c1 is assigned the character a, and c2 remains the character 2.
    c、variable c1 is assigned the character a, and c2 remains uncertain value.
    d、variable c1 is assigned the character a, and c2 is assigned the space character.

6、given the following declarations and scanf function call statements, to make the value of a1, a2, c1, c2 to be 10, 20, a and b respectively. which one of the following inputs is correct? ↙ is used to represent enter key and └┘ is used to represent space. ( d ) int a1,a2; char c1,c2; scanf("%d%d",&a1,&a2); scanf("%c%c",&c1,&c2);
    a、1020ab↙
    b、10└┘20↙ ab↙
    c、10└┘20└┘ab↙
    d、10└┘20ab↙

7、assuming the statement scanf("a=%d,b=%d,c=%d",&a,&b,&c); to make the values of a, b, and c to be 1, 3, 2 respectively, which of the following input is correct? ↙ is used to represent enter key and └┘ is used to represent space.
    a、132↙
    b、1,3,2↙
    c、a=1└┘b=3└┘c=2↙
    d、a=1,b=3,c=2↙

8、if the variable x is of type double, which one of the following statements is right?
    a、scanf("%f",x);
    b、scanf("%f",&x);
    c、scanf("%5.1f",&x);
    d、scanf("%lf",&x);

9、what is the output of the following code? └┘ is used to represent space. float x=-1023.012; printf("%8.3f,",x); printf(" % 10.3f",x);
    a、1023.012,-1023.012
    b、–1023.012,-1023.012
    c、1023.012,└┘-1023.012
    d、–1023.012,└┘-1023.012

10、what is the output of the following code? int x=13,y=5; printf("%d",x%=(y/=2));
    a、3
    b、2
    c、0
    d、1

11、if we declared int a=1234;, what is the result when executing the statement printf("-",a);?
    a、12
    b、34
    c、error
    d、1234

12、what is the output of the following code? int a; char c=10; float f=100.0; double x; a=f/=c*=(x=6.5); printf("%d %d %3.1f %3.1f",a,c,f,x);
    a、1 65 1 6.5
    b、1 65 1.0 6.5
    c、2 65 1.5 6.5
    d、1 65 1.5 6.5

13、execute the following statements, if input 12345678↙,what is the output? int a , b ; scanf("-%*2d=",&a,&b); printf("%d",a b);
    a、46
    b、5690
    c、error
    d、579

14、c compilers are required to check that the number of conversion specifications in a format string matches the number of output items.

15、if the format string is “%d\n”, scanf will skip white space, read an integer, and then skip to the next non-white-space character. so a format string like this can cause an interactive program to “hang” until the user enters a nonblank character.

chapter 3 program control structure -4

quiz 5 selection structure

1、after the execution of the following statements: int a=1, b=2, c=3, d=4, m=2, n=2, cond; cond = (m=a>b) && (n=c>d); , which one of the following value is equal to the value of n ?
    a、1
    b、2
    c、3
    d、4

2、suppose i is a variable of type int, and its value is 10, which of the following is the value of expression 30-i<=i<=9 ?
    a、0
    b、1
    c、9
    d、20

3、after the execution of the following statements: int a=0,b=0,m=0,n=0; (m=a==b)||(n=b==a);,the values of m and n are and respectively?
    a、0 0
    b、1 0
    c、0 1
    d、1 1

4、which of the following is equal to the expression !x ?
    a、x==1
    b、x==0
    c、x!=1
    d、x!=0

5、suppose int x=3,y=4,z=5; , which of the following is the value of the expression !(x y) z-1 && y z/2 ?
    a、6
    b、1
    c、2
    d、0

6、which of the following is not a legal expression in c language?
    a、0<=x<100
    b、x 1=x 1
    c、i=j==0
    d、(char)(x<100)

7、the expression in if(expression) can be .
    a、logical expression
    b、any of the above
    c、relational expression
    d、arithmetic expression

8、when execute the following program: #include int main() { int x,y; scanf("%d%d",&x,&y); if (x>y) x=y;y=x; else x ;y ; printf("%d,%d",x,y); return 0; } which one of the following is correct?
    a、if input 3 and 4, it outputs 4 and 5
    b、syntax error while compiling
    c、if input 4 and 3, it outputs 3 and 4
    d、if input 4 and 3, it outputs 4 and 5

9、in c language, the rule on embedded if statement is that else is always paired with .
    a、the first if
    b、the previous nearest unpaired if
    c、if with the same indent
    d、the most front if

10、if a=1, b=3, c=5, d=4,the value of x is when execute the following program. if (a    a、1
    b、2
    c、3
    d、4

11、which one of the following is equal to the statement y=(x>0 ? 1: x<0 ? -1:0); .
    a、y=0; if (x>=0) if (x>0) y=1; else y=-1;
    b、if (x>0) y=1; else if (x<0) y=-1; else y=0;
    c、if (x) if (x>0) y=1; else if (x<0) y=-1; else y=0;
    d、y=-1; if (x) if (x>0) y=1; else if (x==0) y=0; else y=-1;

12、which one is correct when execute the following code? int x=0,y=0,z=0; if (x=y z) printf("***"); else printf("###");
    a、syntax error while compiling
    b、it outputs ###
    c、it outputs ***
    d、error while linking

13、what is the output of the following program? #include int 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 ; case 3: a ; b ; } printf("a=%d,b=%d",a,b); return 0; }
    a、a=1, b=0
    b、a=2, b=1
    c、a=1, b=1
    d、a=2, b=2

14、if int i=10; the value of i will be after executing the following code. switch (i) { case 9: i =1 ; case 10: i =1 ; case 11: i =1 ; default: i =1 ; }
    a、10
    b、13
    c、11
    d、12

15、given the declaration: float w; int a, b; , which one of the following is a legal switch statement?
    a、switch (w) { case 1.0:printf("*\n"); case 2.0:printf("**\n"); }
    b、switch (b) { case 1:printf("*\n"); default:printf("\n"); case 1 2:printf("**\n"); }
    c、switch (a); { case 1:printf("*\n"); case 2:printf("**\n"); }
    d、switch (a b); { case 1:printf("*\n"); case 2:printf("**\n"); default:printf("\n"); }

16、if int i=1; the value of i will be after executing the following code. switch (i) { case '1': i =1 ; case '2': i =1 ; case '3': i =1 ; default : i =1 ; }
    a、3
    b、2
    c、4
    d、5

17、after the execution of the following statements: int i=5, j=4, k=6 ; float f; f = (i    a、5.0
    b、4.0
    c、6.0
    d、7.0

18、after the execution of the following statements: int m1=5,m2=3; m1>m2 ? (m1=1):(m2=-1);, the values of m1 and m2 are respectively?
    a、1 and -1
    b、1 and 3
    c、5 and -1
    d、5 and 3

19、switch statements can be totally replaced by if statements at any time.

20、the expression in a case label of a switch statement must be constant expression.

21、the statement if and switch can be embedded.

22、the conditional expression and if statement can be totally replaced by each other.

23、duplicate case labels aren’t allowed in switch statement.

24、in switch statement, several case can execute the same program segment.

25、the controlling expression in switch statement can be an expression of any type.

26、the case branch in switch statement can be a compound statement or multiply statement sequence.

27、without break (or some other jump statement) at the end of a case, control will flow into the next case.

chapter 3 program control structure -5

quiz 6 loop structure

1、what is the output of the following program? #include int main() { int x=0,y=5,z=3; while(z-->0&& x<5) y=y-1; printf("%d, %d, %d",x,y,z); return 0; }
    a、3, 2, 0
    b、3, 2, -1
    c、4, 3, -1
    d、5, -2, -5

2、which one of the following contains an infinite loop?
    a、for (i=1;;) { if (i %2==0) continue ; if (i %3==0) break ; }
    b、for (i=1;;) if ( i<10) continue ;
    c、i=32767; do { if (i<0) break ; } while ( i) ;
    d、i=1 ; while (i--);

3、the following code . x=-1; do{ x=x*x; }while (!x);
    a、is an infinite loop
    b、loops for 1 time
    c、loops for 2 times
    d、has syntax error

4、which one of the following statements is correct?
    a、do statement cannot be replaced by the other iteration statements.
    b、do statement will be terminated when its controlling expression is zero.
    c、do statement can only be terminated by break statement.
    d、do statement will be terminated when its controlling expression is non-zero.

5、assume the following code: int n=0,p; do { scanf("%d",&p); n ; } while (p!=12345 && n<3);when , the loop will terminate.
    a、p is not equal to 12345 and n is less than 3
    b、p is equal to 12345 or n is not less than 3
    c、p is equal to 12345 and n is not less than 3
    d、p is not equal to 12345 or n is less than 3

6、given the following for statement: int i,k; for (i=0,k=-1; k=1 ; i ,k ) printf("***"); which one of the following conclusions is correct?
    a、the above for statement contains illegal expression.
    b、the above for statement is an infinite loop.
    c、the above for statement loops for 1 time.
    d、the above for statement never loops.

7、the loop times of the following for statement are . for (i=2; i==0;) printf("%d",i--);
    a、infinite
    b、0
    c、1
    d、2

8、what is the output of the following program? #include int main() { int i,sum; for(i=1;i<6;i ) sum =i; printf("%d",sum); return 0; }
    a、0
    b、unpredictable
    c、14
    d、15

9、assume s, a, b, c are declared as integers, and a, c have been assigned values (c>0), s=a; for(b=1; b<=c; b ) s=s 1;which one of the following is equal to the above code?
    a、s=a b;
    b、s=a c;
    c、s=s c;
    d、s=b c;

10、what is the output of the following program? #include int main() { int i=0,s=0; for (;;) { if(i==3||i==5) continue; if (i==6) break; i ; s =i; }; printf("%d",s); return 0; }
    a、10
    b、it contains an infinite loop and will not output anything.
    c、13
    d、21

11、if the variables i and p have been declared and initialized correctly, which one of the following cannot calculate 5! ?
    a、for(i=1,p=1;i<=5;i ) p*=i;
    b、for(i=1;i<=5;i ) { p=1; p*=i; }
    c、i=1; p=1; while(i<=5) { p*=i; i ; }
    d、i=1; p=1; do{ p*=i; i ; }while(i<=5);

12、in the following programs, which one has the different output with the others’?
    a、k=1 while (1) { s =k ; k=k 1; if (k>100) break ; } printf("%d",s);
    b、int k,s=0; for (k=1;k<=100;s = k); printf("%d",s);
    c、k=1; repeat : s =k ; if ( k<=100) goto repeat printf("%d",s);
    d、k=1; do{ s =k; }while ( k<=100); printf("%d",s);

13、what is the output of the following program? #include int main() { int k=0,m=0,i,j; for (i=0; i<2; i ) { for (j=0; j<3; j ) k ; k-=j ; } m = i j ; printf("k=%d,m=%d",k,m); return 0; }
    a、k=0,m=3
    b、k=0,m=5
    c、k=1,m=3
    d、k=1,m=5

14、which one of the following is not correct?
    a、the statements in c language, except compound statements, must be ended with semicolons.
    b、an empty statement does not affect the program in any location.
    c、compound statements are regarded as one single statement in syntax.
    d、an assignment statement can be made by adding a semicolon at the end of the assignment expression.

15、assume the following program fragment: int k=2; while (k=0) { printf("%d",k) ; k-- ; }which one of the following is correct?
    a、while statement loops for 10 times.
    b、the loop never runs.
    c、the loop is infinite.
    d、the loop runs for only one time.

16、while in do statement can be omitted sometimes.

17、any of the 3 expressions in for loop can be omitted, and so is while and do statement’s controlling expression.

18、the most powerful iteration statement is for statement.

19、the loop body in the for statement will be executed at least once.

20、break can be used in switch statements and loops (while, do, and for), whereas continue is limited to loops.

chapter 4 the preprocessor

quiz 7 preprocessor

1、which one of the following statements is wrong?
    a、preprocessing directive must begin with #.
    b、a line which begins with # in c program is a preprocessing directive.
    c、the preprocessing directives in c program are processed during executing.
    d、preprocessing directives can appear in any line of a c program.

2、which one of the following statements about macro substitute is wrong ?
    a、macro substitute does not occupy the executing time.
    b、macro name does not have data type.
    c、macros must be named with capital letters.
    d、macro substitution is just string substitution.

3、assuming we have #define l(x) 2*3.14*x,thus l(x) is .
    a、function name
    b、function invoking
    c、macro with argument
    d、macro with no arguments

4、assuming we have #define p(x) x/x, what is the output after executing printf("%d",p(4 6)); ?
    a、1
    b、8.5
    c、11
    d、11.5

5、assuming the macro definition #define mod(x,y) x%y, what is the result of the following code? int z,a=15; float b=100; z=mod(b,a); printf("%d",z );
    a、11
    b、10
    c、syntax error
    d、6

6、which one of the following macro for square calculation will not cause ambiguity in any case?
    a、#define power(x) x*x
    b、#define power(x) (x)*(x)
    c、#define power(x) ((x)*(x))
    d、#define power(x) (x*x)

7、given a macro definition as follows: #define n 3 #define y(n) ((n 1)*n), which one of the following is the value of the expression 2*(n y(5 1))?
    a、error
    b、42
    c、48
    d、54

8、given a macro definition #define p(x,y,z) x=y*z; the substitution p(a,x 5,y-3.1) will be .
    a、a=(x 5)*(y-3.1);
    b、a=x 5*y-3.1
    c、a=x 5*y-3.1;
    d、a=(x 5)*(y-3.1)

9、in the file including preprocessing directives, when the file name is enclosed by double quotes after #include, the file will be searched in .
    a、in the standard searching directory of system setting
    b、only in the source file directory
    c、in the source file directory first, then the standard directory searching of system setting
    d、only in the current directory

10、in the file including preprocessing directives, when the file name is enclosed by angle bracket after #include, the file will be searched .
    a、in the source file directory first, then the standard directory searching of system setting
    b、only in the source file directory
    c、in the standard searching directory of system setting
    d、only in the current directory

11、macro substitution does not have type problem, and its arguments are of no type either.

12、in c language standard library header files, many system function prototype are declared. therefore, as long as these functions are used in the program, these header files should be included, for checking the function calling by compiling system.

13、#include directive can include a c source file with function definition.

14、the header files included by #include must have the suffix .h.

chapter 5 array-2

quiz 8 arrays

1、when index the array element, which one of the following statements is wrong?
    a、the array subscript can be integer constant.
    b、the array subscript can be integer expression.
    c、the array subscript can be integer constant or integer expression.
    d、the array subscript can be expression of any types.

2、which one of the following declarations can define a one dimensional array a correctly in c89?
    a、int a(10);
    b、int n=10,a[n];
    c、int n; scanf("%d",&n); int a[n];
    d、#define size 10 int a[size];

3、assume a declaration int a[10]; , which one of the following can reference the element in a correctly?
    a、a[10]
    b、a(5)
    c、a[-10]
    d、a[3]

4、which one of the following statements is wrong?
    a、in c, the arrays cannot be assigned values integrally in an assignment statement.
    b、array name represents the starting address of this array in the memory, which cannot be changed.
    c、the length of an array can be determined by initializer.
    d、if the index of an array element exceeds the range pre-defined, system will give an error message “array index out of bounds”, while executing.

5、assume the declaration int a[3][4]; which one of the following can index the element in a correctly?
    a、a[2][4]
    b、a[3][3]
    c、a[3][4]
    d、a[0][0]

6、assume the declaration int a[3][4]=; which one of the following statements is correct?
    a、only the element a[0][0] is initialized to 0.
    b、it is a wrong statement.
    c、each element in a is initialized but not to 0.
    d、each element in a is initialized to 0.

7、if a 2-d array a has m columns, the formula to index the element a[i][j] is .
    a、j*m i
    b、i*m j-1
    c、i*m j 1
    d、i*m j

8、what is the output of the following code? int k,a[3][3]={1,2,3,4,5,6,7,8,9}; for (k=0;k<3;k ) printf("%d",a[k][2-k]);
    a、3 6 9
    b、1 5 9
    c、1 4 7
    d、3 5 7

9、which one of the following initialization is correct for the 2-d array a?
    a、int a[3][3]={ };
    b、int a[2][2]={1,2,3,4,5,6};
    c、int a[2,3]={1,2,3,4,5,6};
    d、int a[3][3]={1,2,3,4,5,6};

10、assume the declaration int b[]={1,2,[8]=3,4,5,[15]=1,6,7}; the length of array b is .
    a、8
    b、17
    c、uncertain
    d、18

chapter 6 functions

quiz 9 functions

1、which one of the following statements about function is right?
    a、every function can be called by the other functions, including main function.
    b、every function can be compiled separately.
    c、every function can be run separately.
    d、a function can be defined in the function body of another function.

2、which one of the following statements is right?
    a、function definitions can be nested, but function calls cannot be nested.
    b、function definitions cannot be nested, but function calls can be nested.
    c、both function definitions and function calls cannot be nested.
    d、both function definitions and function calls can be nested

3、which one of the following function definitions is right?
    a、double f(int x,int y) { z=x y ; return z ; }
    b、double f(int x,int y) { double z ; z = x y ; return z ; }
    c、double f(int x,y) { double z=x y ; return z ; }
    d、double f(x,y) { int x, y ; double z ; z=x y; return z ; }

4、if call a function int f(), which does not contain any return statement, which one of the following conclusions is right?
    a、this function does not return any value.
    b、this function returns an unpredictable value.
    c、this function returns a system default value.
    d、this function returns the value 0.

5、which one of the following determines the return type of a function in c language?
    a、the expression type in the return statement
    b、the return type specified by function definition
    c、the calling function
    d、compiler

6、which one of the following statements about function return type is wrong?
    a、function return type can be int.
    b、function return type can be array.
    c、function return type can be char.
    d、function return type can be void.

7、which one of the following statements is wrong?
    a、actual parameter can be a constant, a variable or an expression.
    b、formal parameter can be a constant, a variable or an expression.
    c、formal parameter can be of any type.
    d、the data types of formal parameter and actual parameter can be different.

8、which one of the following is right?
    a、a function call must return a value.
    b、actual parameter and formal parameter can have the same name.
    c、the data passed in functions cannot be global variables.
    d、the calling function and the called function must be in the same file.

9、given a function definition as follows: void f(char ch, float x ) { ...... } which one of the following function call statements is right?
    a、f("abc",3.0);
    b、f(32,32);
    c、t=f('d',16.5);
    d、f('65',2.8);

10、assume a program defines a function as follows: double f(double a,double b) { return (a b); } but the definition is written after calling f. therefore, f should be declared before the calling. which one of the following prototypes is wrong?
    a、double f(double,double);
    b、double f(double a,b);
    c、double f(double b,double a);
    d、double f(double x,double y);

11、which one of the following statements about function declaration is wrong?
    a、if the definition of a function precede its calls, its function declaration is not required.
    b、function prototypes of standard c functions are not required.
    c、a function prototype doesn’t have to specify the names of the function’s parameters, as long as their types are present.
    d、c99 has adopted the rule that either a declaration or a definition of a function must be present prior to any call of the function.

12、if an array name is used for an actual parameter in a function calling, which one of the following will be delivered to the corresponding formal parameter?
    a、the value of the 1st element in the array.
    b、the starting address of the array.
    c、all the element values in the array
    d、the number of the elements in the array.

13、given the following code in the main function, which one of the following is an incorrect declaration of the formal argument in function f? int a[3][4]; f(a);
    a、f(int array[3][4])
    b、f(int array[3][])
    c、f(int array[][4])
    d、f(int array[4][3])

14、read the following program: int fun1(double a) { return a*=a;} int fun2(double x,double y) { double a=0,b=0; a=fun1(x); b=fun1(y); return (int)(a b); } if w is a variable of type double, what is the value of w, after executing the statement w=fun2(1.1,2.0);?
    a、5.21
    b、5.0
    c、5
    d、0.0

15、both function definition and function call can be nested.

16、a function must have a return value, otherwise it cannot be defined as a function.

17、specifying that the return type is void indicates that the function doesn’t return a value.

chapter 7 pointers

quiz 10 pointers

1、the pointer of a variable indicates the of the variable.
    a、value
    b、address
    c、name
    d、a symbol

2、given int k=2; int*ptr1,*ptr2; and both ptr1 and ptr2 point to the variable k, which one of the following assignments is not correct?
    a、k=*ptr1 *ptr2
    b、ptr2=k
    c、ptr1=ptr2
    d、k=*ptr1*(*ptr2)

3、given int*p,m=5,n; which one of the following statements is right?
    a、p=&n; scanf("%d",&p);
    b、p=&n; *p=m;
    c、p=&n ; scanf("%d",*p);
    d、scanf("%d",&n); *p=n ;

4、given int*p,a=4; and p=&a; in which one of the following, all items indicate addresses?
    a、a,p,*&a
    b、&a,&*p,p
    c、&*a,&a,*p
    d、*&p,*p,&a

5、if a pointer p points to a variable x, which one of the following is equal to *&x ?
    a、p
    b、x
    c、&x
    d、&*p

6、if the pointer p points to an integer variable x, which one of the following is equal to (*p) ?
    a、p
    b、x
    c、*(p )
    d、&x

7、for two pointer variables of the same base type, which one of the following operations cannot be done?
    a、<
    b、
    c、=
    d、-

8、given the following function and the variable declaration int a=25; which one of the following is the result of the statement print_value(&a); ? void print_value(int *x) { printf("%d", *x); }
    a、23
    b、26
    c、24
    d、25

9、given char s[10]; which one of the following is not the address of s[1]?
    a、s 1
    b、s
    c、&s[0] 1
    d、&s[1]

10、given int a[5],*p=a; which one of the following is a correct reference to an element in array a ?
    a、*&a[5]
    b、*(a 2)
    c、a 2
    d、*(p 5)

11、given int a[5],*p=a; which one of the following is a correct reference to the address of an element in array a ?
    a、p 5
    b、&a[0]
    c、*a 1
    d、&a 1

12、given int x[]={1, 2, 3, 4, 5, 6, 7, 8, 9, 0},*p=x,k; and k is larger than or equal to 0 and less than 10, which one of the following is a wrong reference to the array element x[k]?
    a、*(x k)
    b、p k
    c、x[p-x k]
    d、*(&x[k])

13、given int x[6]={2,4,6,8,5,7},*p=x,i; which one of the following code cannot output the 6 elements in array x in order?
    a、for(i=0;i<6;i ) printf("-",*(p ));
    b、for(i=0;i<6;i ) printf("-",(*p) );
    c、for(i=0;i<6;i ) printf("-",*(p i));
    d、for(i=0;i<6;i ) printf("-",*p );

14、given int a[2][3]; which one of the following is a correct reference to the address of the element in i-th row and j-th column of array a?
    a、*(a[i] j)
    b、a[i] j
    c、(a i)
    d、*(a j)

15、given int a=3,b,*p=&a;which one of the following statements doesn’t assign the value 3 to b?
    a、b=*&a;
    b、b=*a;
    c、b=*p;
    d、b=a;

16、given int a[4][5]; which one of the following references is incorrect?
    a、*a
    b、 a
    c、*(*(a 2) 3)
    d、&a[2][3]

17、given int a[2][3],(*p)[3]; p=a; which one of the following references to an element in the array a is correct?
    a、(p 1)[0]
    b、*(p[1] 1)
    c、*(*(p 2) 1)
    d、p[1] 2

18、given int (*p)[4]; which one of the following statements is right?
    a、p is a pointer to an integer variable
    b、p is a pointer to a 1d array with 4 integer elements
    c、p is a name of the pointer array
    d、p is declared illegally.

19、the return value of the function char* fun(char *p){ return p; } is .
    a、uncertain value
    b、the address value in argument p
    c、the address of a temporary memory unit
    d、the address value of the formal argument

chapter 8 strings

quiz 11 strings

1、which one of the following declarations can define a one-dimensional array a correctly?
    a、int a[5]={0,1,2,3,4,5};
    b、char a[]={0,1,2,3,4,5};
    c、char a={'a','b','c'};
    d、int a[5]="0123"

2、assuming char x[]="12345",y[]={'1','2','3','4','5',''}; which one of the following statements is correct?
    a、x is longer than y.
    b、the lengths of array x and y are equal.
    c、x is shorter than y.
    d、arrays x and y share the same memory area.

3、which one of the following initializations of the character array s is wrong?
    a、char s[5]={"abc"};
    b、char s[5]="abcde";
    c、char s[5]={'a','b','c'};
    d、char s[5]="";

4、which one of the following character arrays cannot be used as a string?
    a、char s[]="happy";
    b、char s[5]={'h','a','p','p','y'};
    c、char s[6]={'h','a','p','p','y',''};
    d、char s[]={"happy"};

5、which is the output of the following code? char c[5]={'a','b','','c',''}; printf("%s",c);
    a、'a''b'
    b、ab
    c、ab c
    d、abc

6、given two arrays of character, a and b, which one of the following statements is correct?
    a、gets(a,b);
    b、scanf("%s%s",a,b);
    c、scanf("%s%s",&a,&b);
    d、gets("a"); gets("b");

7、which is the output of the following code? char a[7]="abcdef"; char b[4]="abc"; strcpy(a,b); printf("%c",a[5]);
    a、└┘
    b、f
    c、\0
    d、e

8、which is the output of the following code? char c[]="\t\b\\\0will\n"; printf("%d",strlen(c));
    a、14
    b、3
    c、9
    d、6

9、which one of the following can be used to test whether the string a is greater than b?
    a、if (a>b)
    b、if (strcmp(a,b)>0)
    c、if (strcmp(a,b))
    d、if (strcmp(b,a)>0)

10、the value of the expression strcmp("3.14","3.278") is .
    a、float number
    b、non-zero integer
    c、0
    d、character

11、given the following code: #include #include int main() { char p[]={'a','b','c'}, q[10]={'a','b','c'}; printf("%d %d", strlen(p), strlen(q)); return 0; } which one of the following statements is true?
    a、when initializing arrays p and q, the system will add the string terminator automatically, so the output lengths are both 3.
    b、the value of strlen(p) is uncertain since p doesn’t have the string terminator, but the string length in array q is 3.
    c、the value of strlen(q) is uncertain since q doesn’t have the string terminator, but the string length in array p is 3.
    d、neither of the lengths of arrays p and q can be determined since they are without the string terminators.

12、which is the output of the following code? char w[][10]={"abcd","efgh","ijkl","mnop"} , k; for(k=1;k<3;k ) printf("%s",w[k]);
    a、abcdfghkl
    b、efghijkl
    c、abcdefgijm
    d、efgjko

13、if the function fun is defined as: void fun(char ch[], float x) { …… }, which one of the following function call statements is correct for function fun?
    a、t=fun('d',16.5);
    b、fun("abc",3.0);
    c、fun('65',2.8);
    d、fun(32,32);

14、which one of the following statements about character array is wrong?
    a、character arrays can store strings.
    b、the character arrays can be assigned values integrally in an assignment statement.
    c、the strings can be input/output integrally.
    d、the strings in the character array cannot be compared by relational operator.

15、which one of the following is correct?
    a、char *a="china"; is equivalent to char *a; *a="china" ;
    b、char *s="china"; is equivalent to char *s; s="china" ;
    c、char str[10]={"china"}; is equivalent to char str[10]; str[]={"china";}
    d、char c[4]="abc",d[4]="abc"; is equivalent to char c[4]=d[4]="abc" ;

16、which one of the following statement(s) is a correct for the string s?
    a、char s[5]={'a','b','c','d','e'} ;
    b、char s[6]="abcde";
    c、char s[6] ; s="abcde";
    d、char *s; scanf("%s",s);

17、given char s[]="china"; char *p ; p=s ; which one of the following is correct?
    a、s and p are exactly equivalent.
    b、*p is equal to s[0].
    c、the content of array s and pointer p is the same.
    d、the length of array s and the length of the string pointed by p are the same.

18、given char a[]="itismine", *p="itismine"; which one of the following is incorrect?
    a、a 1 is the address of character ‘t’
    b、p cannot point to another constant string variable
    c、the address in variable p is changeable.
    d、the array a occupies 9 bytes.

19、given char *cc[2]={"1234","5678"}; which one of the following is correct?
    a、the two elements in array cc store the starting addresses of two 1d character arrays with 4 characters respectively.
    b、the two elements in array cc store the starting addresses of the strings "1234" and "5678" respectively.
    c、cc is a pointer variable which points to a 1d string array with 2 elements.
    d、the elements in the array cc are "1234" and "5678" respectively.

20、assume s1 and s2 are declared correctly, if we want to execute the statement s when string s1 is greater than s2, which one of the following statements is correct?
    a、if(s1>s2)s;
    b、if(strcmp(s1,s2)>0)s;
    c、if(strcmp(s1,s2))s;
    d、if(strcmp(s2,s1)>0)s;

21、given char s1[]="string1",s2[8],*s3,*s4="string2"; which one of the following is incorrect for library function strcpy?
    a、strcpy(s1,s4);
    b、strcpy(s3,"string1");
    c、strcpy(s2,"string1");
    d、strcpy(s2,s1);

chapter 9 structures

quiz 12 structures, union and enumerations

1、given a structure definition as follows: struct stu { int a; float b; } stutype; , which one of the following statements is wrong?
    a、struct is a keyword which is used to declare a structure tag
    b、stutype is a user-defined structure type name
    c、struct stu is a user-defined structure type
    d、a and b are structure members

2、for which one of the following definitions, the compiler will not allocate memory locations.
    a、struct { char name[10] ; int age ; } student ;
    b、struct student { char name[10] ; int age ; } ;
    c、struct student { char name[10] ; int age ; } student ;
    d、struct student { char name[10] ; int age ; } ; struct student student;

3、which one of the following definitions of the structure variable td1 is wrong?
    a、#define aa struct aa aa { int n; float m; } td1;
    b、struct { int n; float m; } aa; stuct aa td1;
    c、struct { int n; float m; } td1;
    d、typedef struct aa { int n; float m; } aa; aa td1;

4、when declare a structure variable, the size of space allocated by system is .
    a、the size of space required by the first member in the structure variable
    b、the sum of the space size required by each member in the structure variable
    c、the memory size of the member which requires the largest space in the
    d、the size of memory required by the last member in the structure variable

5、given the declaration of a structure tag named student as follows: struct student { int no ; char name[20]; char sex; struct { int year; int month ; int day ; } birth; } s; if the member birth of the structure variable s is october 1, 2016. which one of the following assignments is right?
    a、year=2016; month=10; day=1;
    b、s.birth.year=2016; s.birth.month=10; s.birth.day=1;
    c、birth.year=2016; birth.month=10; birth.day=1;
    d、s.year=2016; s.month=10; s.day=1;

6、given the following code, which one of the following statements can output the letter m. struct person { char name[9]; int age; }; struct person class[10]={"johu",17,"paul",19,"mary",18,"adam",16};
    a、printf("%c",class[3].name);
    b、printf("%c",class[2].name[0]);
    c、printf("%c",class[3].name[1]);
    d、printf("%c",class[2].name[1]);

7、which one of the following reference to a member of structure is not right? struct pupil { char name[20]; int age; int sex; } pup[5], *p=pup;
    a、scanf("%s",pup[0].name);
    b、scanf("%d",p->age);
    c、scanf("%d",&pup[0].age);
    d、scanf("%d",&(p->sex));

8、which one of the following reference is not right? struct s { int i1; struct s *i2,*i0; }; static struct s a[3]={2,&a[1],0,4,&a[2],&a[0],6,0,&a[1]}, *ptr=a;
    a、ptr->i1
    b、*ptr->i1
    c、*ptr->i2
    d、 ptr->i0

9、given the following declaration: struct sk { int a; float b; } data; int *p; which one of the following assignments is right, to make p point to a in data?
    a、p=&a;
    b、p=&data.a;
    c、p=data.a;
    d、*p=data.a;

10、given the declaration: struct{int a; char b;} q,*p=&q; which one of the following expression is wrong?
    a、(*p).b
    b、*p.b
    c、q.a
    d、p->a

11、given the following code: struct st { int x; int *y; } *pt; int a[]={1,2},b[]={3,4}; struct st c[2]={10,a,20,b}; pt=c; which one of the following expressions has the value of 11?
    a、*pt->y
    b、 pt->x
    c、pt->x
    d、(pt )->x

12、which one of the following statements about union is right?
    a、a union type cannot contain a member of array.
    b、a union variable cannot store all its members at the same time.
    c、a union variable can store all its members at the same time.
    d、a union type cannot contain a member of type structure.

13、when declare a union variable, the size of space allocated by the compiler is .
    a、the sum of the space size required by each member in the union variable
    b、the memory size of the member which requires the largest space in the union variable
    c、the size of space required by the first member in the union variable
    d、the size of memory required by the last member in the union variable

14、given the following program: union { char a[10]; short b[4][5]; long c[5]; } u; the value of sizeof(u) is .
    a、10
    b、40
    c、20
    d、70

15、given the following program: union data { char ch; int x; } a; which one of the following is not right?
    a、a.x=10;a.x ;
    b、a={'x',10}
    c、a.ch='x';a.ch ;
    d、a.x=10;a.ch='x';

16、given the following declaration: enum color {red,yellow=2,blue,white,black} r=white; what is the output after executing the statement printf("%d",r); ?
    a、0
    b、4
    c、1
    d、3

17、given the following declaration: enum week {sun, mon, tue, wed, thu, fri, sat} day; which one of the following assignments is right?
    a、sun=0;
    b、day=sun;
    c、sun=day;
    d、mon=sun 1;

18、which one of the following statements is wrong?
    a、all elements in union variable have the same beginning address.
    b、a member in a union type can be of type structure, but not of type union.
    c、a union type can be used to declare array and pointers.
    d、if use typedef to give an old type a new identifier, after that, the old type is still valid.

19、given the following statement: typedef struct {int n;char ch[8];} per; which one of the following statements is right?
    a、per is a structure variable name
    b、per is a structure type name
    c、typedef struct is a structure type
    d、struct is a structure tag

chapter 10 files

quiz 13 files

1、which one of the following is correct about data file and c language?
    a、files consist of ascii character sequence and c language can only read and write text files.
    b、files consist of binary data sequence and c language can only read and write binary files.
    c、files consist of records sequence and can be categorized into binary files and text files by the storage form of the data.
    d、files consist of data streams and can be categorized into binary files and text files by the storage form of the data.

2、the system standard input file is .
    a、monitor
    b、floppy disk
    c、hard disk
    d、keyboard

3、the system standard output file is .
    a、hard disk
    b、keyboard
    c、floppy disk
    d、monitor

4、which one of the following is a correct file name argument for the function fopen?
    a、c:\user\text.txt
    b、c:\\user\\text.txt
    c、"c:\user\text.txt"
    d、"c:\\user\\text.txt"

5、given char fname[]="infile.dat"; , which one of the following is a correct way to open the text file infile.dat for reading?
    a、fopen(infile,"r")
    b、fopen("infile","r")
    c、fopen("fname","r")
    d、fopen(fname,"r")

6、which one of the following is a correct way to create a file for both reading and writing using the function fopen ?
    a、"ab "
    b、"rb "
    c、"ab"
    d、"wb "

7、if errors occur while executing the function fopen, what is its return value?
    a、the address
    b、1
    c、eof
    d、null

8、if open an existing file using the argument "a ", which one of the following is correct?
    a、when it is open, the origin file content remains, the accessing pointer moves to the beginning of the file and rewriting/reading operations are available.
    b、when it is open, the origin file content is deleted, only reading operation is available.
    c、none of the above is correct.
    d、when it is open, the origin file content remains, the accessing pointer moves to the end of the file and appending/reading operations are available.

9、in the file open modes, the string "rb" indicates .
    a、opening a text file only for data writing.
    b、opening an existing text file only for data reading.
    c、opening a binary file only for data writing.
    d、opening an existing binary file only for data reading.

10、when opening the text file "a:\\aa.dat" in the mode "w", if the file already exists, .
    a、the new data will be appended to the end of the file.
    b、the error message will be displayed.
    c、the new data will be insert into the beginning of the file.
    d、the file will be clear and the new data is written from the beginning.

11、in c program, which one of the following can write an integer data into a file in binary form?
    a、fprint
    b、fputs
    c、fputc
    d、fwrite

12、which one is the prototype of the function fputc that write a character to the disk files?
    a、file* fputc(char)
    b、int fputc(file *)
    c、int fputc(file *,char)
    d、int fputc(char,file *)

13、which one of the following operations can be done using the function fseek?
    a、sequential file access
    b、random file access
    c、all of the above
    d、changing the file position associated with the file pointer.

14、the function calling fseek(fp,-20l,seek_end) complete the operation .
    a、moving the file pointer to the location 20 bytes to the file header.
    b、moving the file pointer 20 bytes forward from the current location.
    c、moving the file pointer 20 bytes backward from the current location.
    d、moving the file pointer 20 bytes backward from the end of the file.

15、which one of the following codes is nearly equal to fseek(fp,0l,seek_set)?
    a、feof(fp)
    b、ftell(fp)
    c、fgetc(fp)
    d、rewind(fp)

16、the function rewind can .
    a、move the file pointer to the specific location of the file.
    b、move the file pointer to the end of the file.
    c、move the file pointer to the location of the next character.
    d、move the file pointer to the beginning of the file.

17、the function ftell(fp) can .
    a、move the pointer of the stream file.
    b、initialize the pointer of the stream file.
    c、all the above.
    d、get the current location of the stream file.

final examination

part1-objective questions

1、which of the following is a legal c identifier?
    a、99npu
    b、abc@npu
    c、my_npu
    d、your-npu

2、in c language, which of the following operator requires its operands must be of type int?
    a、/
    b、*
    c、%
    d、=

3、the following code . a=-1; do{ a=a*a; }while (!a);
    a、is an infinite loop
    b、loops for 2 times
    c、loops for 1 time
    d、has syntax error

4、suppose int x=3,y=4,z=5; , which of the following is the value of the expression !(x y) z-1 && y z/2 ?
    a、6
    b、2
    c、1
    d、0

5、suppose that we call scanf as follows: scanf(“%f%d%f”, &a, &c, &b); if the user enters: 12.3 45.6 321 what will be the values of a, c, and b after the call? (assume that a and b are double variables and c is an int variable.)
    a、12.3 45 321
    b、12.3 45.6 321
    c、12.3 45 0.6
    d、12 45 321

6、if c is a variable of type char, which one of the following statements is illegal?
    a、i = c; /*i has type int*/
    b、c = 2*c – 1;
    c、putchar(c);
    d、printf(c);

7、what is the output of the following code? int a; char c=10; float f=100.0; double x; a=f/=c*=(x=6.5); printf("%d %d %3.1f %3.1f",a,c,f,x);
    a、1 65 1 6.5
    b、1 65 1.0 6.5
    c、2 65 1.5 6.5
    d、1 65 1.5 6.5

8、execute the following statements, if input 87654321↙,what is the output? int a , b ; scanf("-%*2d=",&a,&b); printf("%d",a b);
    a、46
    b、579
    c、error
    d、519

9、after the execution of the following statements: int a=1, b=2, c=3, d=4, t1=2, t2=2, k; k = (t1=a>b) && (t2=c>d); , which one of the following value is equal to the value of t2 ?
    a、1
    b、2
    c、3
    d、4

10、suppose int a=3,b=4,c=5; , which of the following is the value of the expression !(a b) c-1 && b c/2 ?
    a、6
    b、1
    c、2
    d、0

11、assume a declaration int t[10]; , which one of the following can reference the element in t correctly?
    a、t[10]
    b、t(5)
    c、t[-10]
    d、t[3]

12、assume the declaration int b[]={1,2,[8]=3,4,5,[15]=1,6,7,9}; the length of array b is .
    a、8
    b、15
    c、19
    d、uncertain

13、what is the output of the following code? int k,a[3][3]={3,2,3,3,5,6,7,3,9}; for (k=0;k<3;k ) printf("%d",a[k][2-k]);
    a、3 6 9
    b、3 5 9
    c、3 2 3
    d、3 5 7

14、given a structure definition as follows: struct mystr { int a; float b; } mytype; , which one of the following statements is wrong?
    a、struct is a keyword which is used to declare a structure tag
    b、mytype is a user-defined structure type name
    c、struct mystr is a user-defined structure type
    d、a and b are structure members

15、which is the output of the following code? char w[][10]={"abcd","efgh","ijkl","mnop"} , k; for(k=1;k<3;k ) printf("%s",w[k]);
    a、abcdfghkl
    b、efghijkl
    c、abcdefgijm
    d、efgjko

16、the loop body in the for statement will be executed at least once.

17、without break (or some other jump statement) at the end of a case, control will flow into the next case.

18、in switch statement, several case can execute the same program segment.

19、the expression in a case label of a switch statement must be constant expression.

20、the three identifiers, wendy, wendy and wendy, are equal in c language.

part2-subjective questions

1、lao wang sold apples in n days (n < = 5). for example, n is five days. on the first day, he sold half of all the apples plus half an apple; the next day, he sold one third of the remaining apples plus one third of an apple; on the third day, he sold 1/4 of the remaining apples plus 1/4 of an apple; on the fourth day, he sold 1/5 of the remaining apples and 1/5 of an apple, and on the last day, he sold the remaining 11 apples. input n and output the number of apples at the beginning (you can't cut the apples when you sell them). the intput is an integer which is no more than 5 the output is an integer. we will test 5 kinds of data. your will get all the scores if your code pass 5 times of judge. submit your porgram here.

2、please describe the functions of the arrays, such as when or why should we use arrays, what problems we can solve with arrays, etc.

3、according to your answer above, design a programming question about the arrays, and write the program with comments. so , you shoulde write: your question about the arrays your code (your program) with comments

4、please describe the functions of the pointers, such as when or why should we use pointers, what problems we can solve with pointers, etc.

5、according to your answer above, design a programming question about the pointers, and write the program with comments. so , you shoulde write: 1. your question about the pointers. 2. your code (your program) with comments

<< 上一篇

备案号: 凯发娱乐官网的版权所有 凯发k8一触即发 copyright © 2012-2023 凯发k8一触即发-凯发娱乐官网 all rights reserved. sitemap

网站地图