This document contains 15 questions about C programming concepts like operators, loops, precedence, and switch statements. It tests knowledge of code output, expressions, and writing basic loops. The questions cover a wide range of fundamental C programming topics.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
37 views
Assessment Test 1
This document contains 15 questions about C programming concepts like operators, loops, precedence, and switch statements. It tests knowledge of code output, expressions, and writing basic loops. The questions cover a wide range of fundamental C programming topics.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
Assessment Test 1
1. What is the output of the following code ?
printf("One%d",printf("Two%d",printf("Three")));
2. What is the output of the following code ?
printf("%d",printf("%d",scanf("%d%d",&a,&b)));
3. If y is of integer type, then the expressions
3 * ( y – 8 ) / 9 and ( y – 8 ) / 9 * 3 will yield the same value if a) y is an even number b) y is an odd number c) y – 8 is an integral multiple of 9 d) y – 8 is an integral multiple of 3 4. Predict the output of the following code fragment int x, y = 2, z, a; x = ( y *= 2 ) + ( z = a = y ); printf (“%d”, x); a) 8 b) 6 c) 7 d) 5 5. printf(“%c”,100) a) prints 100 b) prints ASCII equivalent of 100 c) prints garbage d) none of the above 6. What does n << 3 + n do? a) multiply by 9 b) divide by 9 c) multiply by 8 d) n % 9 7. The expression 5 - 2 - 3 * 5 - 8 / 2 + 16 % 9 / 7 evaluates to a) -16 b) -14 c) -17 d) -15 8. When two operators have same precedence, resolution is done using a) precedence b) associativity c) left to right d) right to left 9. float x = 10 / 3 + 40 / 7 * 2 The value stored in the variable x is ________________ 10. The following loop for(i =1, j = 10; i < 6; ++i, --j) printf(“%d %d ”, i, j); a) 1 10 2 9 3 8 4 7 5 6 b) 1 2 3 4 5 10 9 8 7 6 c) 1 1 1 1 1 9 9 9 9 9 d) none of the above 11. Predict the output if (a = 0) printf(“a is zero”); else printf(“a is not zero”); a) a is zero b) garbage c) nothing d) a is not zero 12. Predict the output for (i = 3; i < 15; i += 3) { printf(“%d”, i); i++; } a) 3 6 9 12 b) 3 6 9 12 15 c) 3 7 11 d) 3 7 11 15 13. Predict the output while(printf(“%d”,printf(“az”)) printf(“by”); a) azbybybyby… b) azbyazbyazbyazby… c) az2byaz2byaz2by… d) none of the above 14. Write a for loop that prints the following 1 22 333 4444 55555
15. The constant expressions in switch statement case labels can be
a) character b) integer c) a or b d) floating point