Operators and Expressions II-51
36. What is the output of the following program?
void main()
{
int a=16,b=4;
clrscr();
printf("%d",a<<a/b-2;
}
OUTPUT:
64
Explanat ion: In the above program a/b – 2 works out to be 2. As per precedence of operators, divi-
sion operator is performed first and then subtraction. Hence, a is shifted right two bits and, therefore,
result is 64.
37. What is the result of 5&&2?
Ans: 1
Explanation: Logical ANDing between 5 and 2 is 1. Hence, the result is 1.
Multiple-choice Questions
Examples on Arithmetic Operators
1. What is the remainder of 9% 10 ?
(a) 5 (b) 2 (c) 1 (d) 9
2. What is the result of the expression ((10*2)*(10/5)%11)?
(a) 7 (b) 10 (c) 8 (d) None of them
3. What is the result of expression (float)(12/4) * (int) 5. 3 ?
(a) 15.0000000 (b) 1 (c) 3 (d) None of them
4. What is the result of 4|2?
(a) 1 (b) 6 (c) 2 (d) 0
5. Which of the following bracket is suitable for evaluation of arithmetic operations ?
(a) [ ] (b) { } (c) ( ) (d) None of the above
6. Multiplication (*) and division( / ) operators have priority than addition (+) operator.
(a) Lower (b) Higher (c) Similar
Examples on Logical Operators
7. What is the result of 10&&4?
(a) 0 (b) 1 (c) 2 (d) 5
8. The && operator is used to .
(a) Compare two numeric value (b) Compare two float values
(c) Compare two Boolean values (d) None of the above
M03_ITL-ESL4791_02_SE_C03.indd 51 12/22/2012 5:00:08 PM