Operators and Expressions 63
{
in t a ,b ,c ;
a=9;
b=10;
c= (b<a | | b>a);
c lr s c r ();
printf ("
c=%d",c);
}
OUTPUT:
a) c=l b) c=0 c) c=-l d) none of the above
C) A ttem pt the following programs.
1) Write a program to shift the entered number by three bits left and display the result.
2) Write a program to shift the entered number by five bits right and display the result.
3) Write a program to mask the most significant digit of the entered number. Use AND operator.
4) Write a program to enter two numbers and find the smallest out of them. Use conditional
operator.
5) Write a program to enter a number and carry out modular division operation by 2,3 and 4 and
display the remainders.
6) Attempt the program (5) with division operation and find the quotients.
7) Write a program to enter an integer number and display its equivalent values in octal and
hexadecimal.
8) Write a program to convert hexadecimal to decimal numbers. Enter the numbers such as 0x1 c,
0x18, Oxbc, Oxcd etc.
9) Write a program to find the average temperature of five sunny days. Assume the temperature in
Celsius.
10) Write a program to enter two numbers. Make the comparison between them with conditional
operator. If the first number is greater than second perform multiplication otherwise division
operation.
11) Write a program to calculate the total cost of the vehicle by adding basic cost with a) excise duty
(15%) b) Sales tax (10%) c) Octroi (5%) and d) Road tax (1%). Input the basic cost.
12) Write a program to display ASCII equivalents of
a) 'A ', and ' a ' , ' b ' , ' c ' .
b) 'a '- 'C ' , 'b '-'A ' and 'c ' - ' B ' .
c) xa' + ' c ' , 'b '* 'a ' and 'c'+ 1 2 .
13) Write a program to enter a number that should be less than 100 and greater than 9. Display the
number in reverse order using modular division and division operation
14) Write a program to enter a four-digit number. Display the digits of the number in the reverse
order using modular division and division operation. Perform addition and multiplication of
digits.
15) Write a program to display numbers from 0 to 9. Use ASCII range 48 to 59 and c o n trol s trin g
%c.
16) Write a program to evaluate the following expressions and display their results.
a) x2 +2 x3* (2*x)
b) xl+y2+z3
where, x, y and z are integers.
17) Write a program to print whether the number entered is even or odd use conditional operator?