Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

6. What will be printed when the sample code is executed? int x-1; for (x4;x++)

ID: 3909632 • Letter: 6

Question

6. What will be printed when the sample code is executed? int x-1; for (x4;x++) printf("%d ", 2 * x); 7. Assuming a double is 8 bytes long, what will be printed by the following code? double arr[41(3]-((1), (2, 3), (4, 5, 6) h printf( "%d ", sizeof( arr ) ); What is printed when the sample code is executed? y + 2; 8. inty[4]s {10, 20, 30, 40); int *ptr printf("%d ", *ptr); 9. What will print when the following code is executed? int i # 2, x 9; double z; printf"z-%.2fn", z) 10. What number is equivalent to 1.2e-3?

Explanation / Answer

ANSWER 6: In this question, we initialize the x=1 and in the for loop initialization can be done outside of the loop so here it will simply execute the loop and print 2468. because x will start from 1.

ANSWER 7: if one double take 8 bytes so here array has the 4*3=12 elements so it will have the size 96 bytes because space will be allocated to the whole array.

ANSWER 8: initially ptr point to the initial value of the array but after int *ptr=y+2 it will increase the value and now it will point to the third member of the array. so output will be 30.

ANSWER 9: It will be 4.00 because x/i will give the integer value because the division has the greater preference than assignment so after that it will assign to the z and we are printing the value z for two decimals.

ANSWER 10: 1.2e-3 will be 0.0012