Operators and Expressions II-55
24. In C language, the notation for ‘not equal to’ is .
(a) = ! (b) != (c) ~! (d) ^!
25. Which of the following operator/s in C have the highest precedence?
(a) Comma operator (b) Arithmetic operators
(c) Logical operators (d) Bitwise operators
26. Which of the following operator in C has the highest precedence?
(a) * (b) + (c) <=  (d) ~
27. Which of the following increment and decrement operators respectively in C are valid?
(a) + and – (b) ++ and – – (c) =+ and = (d) += and –=
28. Which of the following operator requires three operands?
(a) Right shift (>>) (b) Comma (,)
(c) Ternary operator (?:) (d) Logical AND (&&)
29. Compile time operator is .
(a) Comma (b) Modulus (c) Right shift (d) sizeof()
30. Which data type is required for modules operator?
(a) Floating (b) Character (c) Integer (d) Long floating
31. What is the result of the following statement?
printf("%f", (float)14/3);
(a) 2.3 (b) 3.2 (c) 3.00 (d) 4.66
32. Which of the following is not a formatted function?
(a) scanf() (b) printf() (c) gets() (d) None of the above
33. What is the output of sizeof (float)?
(a) 2 (b) 1 (c) 4 (d) 8
34. p% q means
(a) (p - (p/q)*q) (b) (p + ( p/q)*q) (c) (p*(p/q)*q) (d) None of the above
35. Bit wise ^ (EX_OR) operator is used for .
(a) Addition of numbers (b) Subtraction of numbers
(c) Multiplication of numbers (d) Compliment the bits
36. Which of the following is Boolean operator for logical OR?
(a) & (b) | (c) ! (d) &&
37. Which of the following is Boolean operator for logical EXOR?
(a) & (b) |  (c) ^ (d) ||
38. Which of the following is Boolean operator for logical NOT (inverter)?
(a) ~ (b) |  (c) ^
M03_ITL-ESL4791_02_SE_C03.indd 55 12/22/2012 5:00:08 PM
II-56 Programming Concepts
Answers
1. (d) 2. (a) 3. (a) 4. (b) 5. (c) 6. (b) 7. (b) 8. (c) 9. (b) 10. (b)
11. (a) 12. (a) 13. (b) 14. (a) 15. (a) 16. (a) 17. (b) 18. (b) 19. (a) 20. (a)
21. (a) 22. (a) 23. (a) 24. (b) 25. (b) 26. (a) 27. (b) 28. (c) 29. (d) 30. (c)
31. (d) 32. (c) 33. (c) 34. (c) 35. (d) 36. (b) 37. (c) 38. (a)
True or False
1. + is symbolic representation of increment operator.
2. In C, x=x–1 can be written as x– –.
3. Number of bytes needed to store a variable is indicated by sizeof() operator.
4. The ‘&’ operator prints address of the variable.
5. >> is the relational operator.
6. >= is the binary operator.
7. != is the relational operator.
8. The logical AND (&&) operator provides true result when both expressions are true.
9. The logical NOT operator (!) provides 0 if the condition is true otherwise 1.
10. The logical OR (||) operator provides false result when one of the expressions is true.
11. Bitwise EX-OR operation is performed by the operator &.
12. One’s complement is performed by operator ~.
13. Bitwise OR is performed by the operator |.
Answers
1. False 2. True 3. True 4. True 5. False 6. False 7. True 8. True 9. False 10. False 11. False
12. True 13. True
Additional Questions
What are the outputs of the following programs?
Questions on arithmetic operators 
1. Enter basic salary of an employee as Rs 20000 and compute the output of the following program
void main()
{
float bas=20000,tot;
clrscr();
M03_ITL-ESL4791_02_SE_C03.indd 56 12/22/2012 5:00:08 PM
Operators and Expressions II-57
tot=bas+0.30*bas+0.18*bas;
printf("Total salary = %10.2f ",tot);
getche();
}
OUTPUT:
Total salary = 29600.00
2. Program on some arithmetic operators
void main()
{
int a=32763, b=5,c;
unsigned int p=65535,q=1,r;
clrscr();
c=a+b,
r=p+q;
printf(" c= %d",c);
printf(" r= %u",r);
getche();
}
OUTPUT:
c = -32768
r = 0
3. Enter the principal amount, year and rate of interest as 5000 3 2 respectively. Find the output?
void main()
{
int prin=2000,year=2;
float rate=5,simple;
clrscr();
simple=prin*rate*year/100;
printf(" %5.2f ",simple);
getche();
}
OUTPUT:
200.00
M03_ITL-ESL4791_02_SE_C03.indd 57 12/22/2012 5:00:08 PM
II-58 Programming Concepts
4. Enter the radius and compute the area of the circle?
void main()
{
float area,radius=3.5;
const float pi=3.1413;
clrscr();
area=pi*radius*radius;
printf(" Area of a circle =%2.2f",area);
getche();
}
OUTPUT:
Area of a circle = 38.48
5. Program to convert decimal 10 in to Binary
void main()
{
int n=10,i,x=7,y=3;
clrscr();
printf("Binary equivalent of decimal numer 10 is");
while(n!=0)
{
i=n%2;
n=n/2;
gotoxy(x,y);
printf("%d",i);
x--;
}
getch();
}
OUTPUT:
Binary equivalent of 10 is 1010
6. Program on arithmetic operators.
#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
printf("%d",1000%5);
M03_ITL-ESL4791_02_SE_C03.indd 58 12/22/2012 5:00:08 PM
Operators and Expressions II-59
printf("%d",1010%10);
printf("%d",11010%15);
printf("%d",0101110%20);
getche();
}
OUTPUT:
00012
Examples on relational operators 
7. Program on relational operators.
void main()
{
int x=40,y=80;
clrscr();
x<<=1,y>>=2;
printf("%d %d ",x,y);
getche();
}
OUTPUT:
80 20
8. Program on simple problem
void main()
{
clrscr();
printf(" %d",15==15);
printf(" %d",11>=15);
printf(" %d",7<8);
printf(" %d", 'C'=='c');
getche();
}
OUTPUT:
1010
M03_ITL-ESL4791_02_SE_C03.indd 59 12/22/2012 5:00:08 PM
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset