Assignment 15 Shorthandoperator Ans
Assignment 15 Shorthandoperator Ans
a. Miscellaneous Operators
b. Bitwise Operators
c. Unary Operators
d. None of the Above
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
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
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
#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!
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!
a. 10
b. 11
c. RUNTIME ERROR!
d. SYNTAX ERROR!
Answer - b. 11
a. SYNTAX ERROR!
b. RUNTIME ERROR!
c. 10
d. 11
Answer - d. 11