当前位置:网站首页>3. Sequential structure multiple choice questions

3. Sequential structure multiple choice questions

2022-06-25 14:57:00 --988

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

1. In the format C Call in language printf Attention should be paid to when outputting , In the format control string , The format description and the number of output items must be the same . If the number of format descriptions is less than the number of output items , The extra output items will ( ); If the number of format descriptions is more than the number of output items , For redundant formats, the indefinite value will be output ( or 0).(A)

A. No output

B. Output space

C. Output as usual

D. Output variable value or 0


2. stay scanf Function format control , The format description type should match the input type one by one . If the type doesn't match , System (B ).

A. Not accepted

B. No error message is given , But it is impossible to get the correct information and data

C. Can accept correct input

D. Give error message , Do not accept input

#include<stdio.h>

int main(void)

{

int i=010,j=10,k=0x10;

printf("%d,%d,%d\n",i,j,k);

return 0;

}

A.8,10,16

(i It's octal. ,j It's decimal ,k It's hexadecimal )

4. It has the following definitions

int x=10,y=5,z;

printf("%d\n",z=(x+=y,x/y));

The output of is (3).

Operators of the same priority , The operation order is determined by the combination direction .

Just remember :!> Arithmetic operator > Relational operator >&&>||> Assignment operator

, The combining direction of the comma operator is from left to right , The final result is determined by the last expression .

C Language operator priority

5. Write the output of the following program (C).

#include<stdio.h>

int main(void)

{

int i,j;

i=20;

j=(++i)+i;

printf("%d",j);

i=13;

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

return 0;

}

C.42 13 13

front ++: to ++ operation , And then I'll take part in the calculation .

after ++: Take part in the calculation first , Proceed again ++ operation .( Self increase is similar to self decrease )

6.printf The formatter is used in the function "%4s", And the numbers 4 Stands for the output string 4 Column . If the string length is greater than 4, Then all the characters will be output from left to right according to the original character length ; If the string length is less than 4, Then the output mode is ( C).
A. Output the string from the left , Fill in the right space
B. Output all from left to right according to the original character length

C. Right align to output this character , Left padding
D. Output error message


7. The output of the following program is (D ).
int main(void)
{ intk=11;
printf("k=%d,k=%o,k=%x\n",k,k,k);
return 0; }
A.k=11,k=12,k=11
B.k=11,k=13,k=13
C.k=ll,k=013,k=Oxb

D.k=11,k=13,k=b


8. Assume w、x、y、z、m Are all int Type variable , Then run the following program segments ,m The value of is ( D).
w=1; x=2; y=3; z=4;
m=(w<x)?w:x; m=(m<y)?m:y; m=(m<z)?m:z;
A.4
B.3
C.2

D.1

The conditional operator is C The only binomial operator in a language , The grammar format is : expression 1? expression 2: expression 3, The evaluation rule is : If the expression 1 The value of is true , The expression 2 As the value of the entire conditional expression , Otherwise, the expression 3 As the value of the entire conditional expression .


9. Suppose you enter... From the keyboard 23456< enter >, The output of the following program is ( C).
#include<stdio.h>
int main (void )
{ int m,n;
scanf("%2d%3d", &m,&n);
printf("m=%d n=%d\n",m,n);
return 0;
}
A.m=23 n=45
B.m=234 n=56

C.m=23 n=456
D. Statement has errors


10. Known characters a Of ASCII Decimal code is 97, The output result after executing the following program segments is (D ).
char ch:int k:
ch='a'; k=12;
printf("%c, %d,",ch,ch,k);
printf("k=%d\n",k);
A. The dependent variable type does not match the type of the format descriptor, and the output has no fixed value
B. The output item does not match the number of format descriptors , The output is zero or indefinite
C.a,97,12k=12

D.a,97,k=12


原网站

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