0% found this document useful (0 votes)
9 views

Assignment 15 Shorthandoperator Ans

The document contains 20 multiple choice questions about C operators and loops. It tests knowledge of unary operators like increment/decrement, the difference between pre-increment and post-increment, and the proper syntax of while, do-while and for loops.

Uploaded by

Yash rai
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
9 views

Assignment 15 Shorthandoperator Ans

The document contains 20 multiple choice questions about C operators and loops. It tests knowledge of unary operators like increment/decrement, the difference between pre-increment and post-increment, and the proper syntax of while, do-while and for loops.

Uploaded by

Yash rai
Copyright
© © All Rights Reserved
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/ 11

Assignment of objective questions

1. Increment/Decrement operator falls in the category of…

a. Miscellaneous Operators
b. Bitwise Operators
c. Unary Operators
d. None of the Above

Answer - c. Unary Operators

2. Which of the following is the Unary Operator?

a. *, /
b. /, %
c. ++, --
d. None of the above

Answer - c. ++, --
3. Which of the following is not a unary operator?

a. --
b. ++
c. sizeof ()
d. %

Answer - d. %

4. Is “+” and “– “are Arithmetic operators are they also Unary Operator?

a. Yes
b. No
c. Only for Modern Compilers
d. Only for Turbo Compiler

Answer - a. Yes

5. The associativity of increment/decrement operator is from…

a. Right-To-Left
b. Left-To-Right
c. Compiler Dependent Behavior
d. Platform-Dependent Behavior

Answer - a. Right-To-Left
6. When we put increment/decrement operator after operand then it is called…

a. Pre-Increment
b. Post-Increment
c. SYNTAX ERROR
d. None of the above

Answer - b. Post-Increment

7. When we put increment/decrement operator before operand then it is called…

a. Pre-Increment
b. Post-Increment
c. SYNTAX ERROR
d. None of the above

Answer - a. Pre-Increment
8. Find the output of the following program (in Turbo Compiler)
main ()
{
int x = 3, y;
y = ++x * ++x * ++x;
printf ("x = %d, y = %d", x, y);
}

a. x = 5, y = 60
b. x = 6, y = 216
c. x = 5, y = 125
d. x = 6, y = 150

Answer - b. x = 6, y = 216

9. Find the output of the following program (in Turbo Compiler)


int a = 10, b;
b = a++ + ++a;
printf ("b = %d, a++ = %d, a = %d, ++a = %d", b, a++, a, ++a);

a. 12, 10, 11, 13


b. 22, 13, 14, 14
c. 22, 11, 11, 11
d. 22, 13, 13, 13

Answer - d. 22, 13, 13, 13


10. Find the output of the following program (in Turbo Compiler)

#include <stdio.h>
int main ()
{
int x = 1;
int y = (x++, x++, x++);
printf ("x = %d, y = %d\n", x, y);
return 0;

a. x = 4, y = 3
b. x = 4, y = 4
c. x = 1, y = 1
d. x = 3, y = 3

Answer - a. x = 4, y = 3

11. Which of the following syntax is correct for the while statement?

a. while(<test_cond>):
b. while(<test_cond>);
c. while(<test_cond>)
d. while <test_cond>

Answer - c. while(<test_cond>)
12. Which of the following syntax is correct for the while statement?

a. do{<body_of_loop>}while(<test_cond>):
b. do{<body_of_loop>}while(<test_cond>);
c. do{<body_of_loop>}while(<test_cond>)
d. do{<body_of_loop>}while <test_cond>

Answer - b. do{<body_of_loop>}while(<test_cond>);

13. Find the output of the following program (in Turbo Compiler)
int i = 1;
while (i <= 10);
{
i++;
}
printf ("i = %d\n", i++);

a. 10
b. 11
c. RUNTIME ERROR!
d. SYNTAX ERROR!

Answer - c. RUNTIME ERROR!


14. Find the output of the following program (in Turbo Compiler)
int i = 1;
while (i <= 10)
{
i++;
}
printf ("i = %d\n", i++);

a. 10
b. 11
c. RUNTIME ERROR!
d. SYNTAX ERROR!

Answer - b. 11
15. Find the output of the following program (in Turbo Compiler)
int i = 1;
do
{
i++;
} while (i <= 10)
printf ("i = %d\n", i++);

a. 10
b. 11
c. RUNTIME ERROR!
d. SYNTAX ERROR!

Answer - d. SYNTAX ERROR!


16. Find the output of the following program (in Turbo Compiler)
int i = 1;
do
{
i++;
} while (i <= 10);
printf ("i = %d\n", i++);

a. 10
b. 11
c. RUNTIME ERROR!
d. SYNTAX ERROR!

Answer - b. 11

17. "while" statements are also known as…

a. Entry Controlled Loop


b. Exit Controlled Loop
c. NULL Loop
d. None of the above

Answer - a. Entry Controlled Loop


18. "do...while" statements are also known as…

a. Entry Controlled Loop


b. Exit Controlled Loop
c. NULL Loop
d. None of the above

Answer - b. Exit Controlled Loop

19. "for" statements are also known as…

a. Entry Controlled Loop


b. Exit Controlled Loop
c. NULL Loop
d. None of the above

Answer - a. Entry Controlled Loop


20. Find the output of the following program (in Turbo Compiler)
int i;
for (i = 1; i <= 10; i++);
printf ("i = %d", i);

a. SYNTAX ERROR!
b. RUNTIME ERROR!
c. 10
d. 11

Answer - d. 11

You might also like