Вы находитесь на странице: 1из 2

>Section 2 - Cad/Cad Software > >1)double x = 1/2.0 + 1/2; printf("x=%.

2f\n", x); What will be printed when >the sample code above is executed? > x=0.00 > x=0.25 > x=0.50 > x=0.75 >2)int j=3; if (j == 3) j = 4; {int j = 1;} printf("j=%d\n", j); What will >be >the outcome when the sample code above is >executed? > 1) It will not compile since j can not be declared twice. > The output is not predictable. > It will print out: j=1. > It will print out: j=4. >3)char buf[5] = "a"; const char *ptr = buf; Given the above, which of the >following statements is legal? > ptr = buf; > *ptr = "a"; > *ptr = buf; > ptr = 'a'; >4)void myFunc (int x) void myFunc (int x) { if (x > 0) myFunc(--x); >printf("%d, ", x); } int main() { myFunc(5); return >0; } What will the above sample code produce when executed? > 1, 2, 3, 4, 5, 5, > 0, 0, 1, 2, 3, 4, > 5, 4, 3, 2, 1, 0, > 0, 1, 2, 3, 4, 5, >5)int x[2][2]; Which of the following are legal ways to initialize the >array >shown above? > x[1,1] = 1; x[1,2] = 2; x[2,1] = 3; x[2,2] = 4; > x[2][2] = {1; 2; 3; 4 }; > x[2][2] = {{1, 2} {3, 4}}; > None of the above >6)"The stock's value decreased by 10%." Select the statement which will >EXACTLY reproduce the line of text above. > printf( "The stock's value decreased by %d%.\n", 10 ); > printf( "\"The stock\'s value decreased by %d\%\.\"\n", 10 ); > printf("\"The stock\'s value decreased by %d%\.\"\n"); > printf( "\"The stock's value decreased by %d%%.\"\n", 10 ); >7)main() { float i=33.2; printf("i= %f", i%3); } What will be the output of >print statement? > 0.2000 > 0.0000 > : 0.6666 > : Error >8)main() { char s[20],*h; strcpy(s,"EACoEisaGE-TATAcompany"); >h=strstr(s,"TATA"); strcpy(h,"EACoE"); printf("\n >Value of s=%s",s); } What would be the output of the following code ? > EACoE > EACoEisaGE-TATAcompany > TATA > EACoEisaGE-EACoE >9)17. What would be the output of this program. main() double i; switch

(i) >{ >case 1.1: printf("Case 1.1"); break; case 1.2: >printf("Case 1.2 "); break; case 1.3: case 1.2: case 1.1: printf("All >cases"); break; } What would be the output if value of i >is 1.2? > Case 1.2 > Compilation error > All cases > Run time error >10)main() { static int h; int p p= 5/h; printf("%d",p); } > 5 > Run time Error > An arbit number > Will not run becaue value of h is not defined >11) > > >