Birla Institute of Technology & Science, Pilani
Birla Institute of Technology & Science, Pilani
Birla Institute of Technology & Science, Pilani
Question 1a) Make a single line comment on each of the following [3]
i) Switch statement cannot have float values in case labels.
ii) C program can’t handle octal and hexadecimal constants.
iii) User defined function can be called from main function, from macros and from another user
defined function.
Question 1b) Provide the output for each of these code (there is no error) with explanation [3]
i) #include <stdio.h>
void main() {
static int var = 5;
printf("%d ", var--);
if(var)
main();
}
ii)#include <stdio.h>
void main() {
int a =2,b=0,c,d;
c = 16>>2 ;
d = (a++) - (- -b);
printf("a=%d, b=%d, c=%d, d=%d",a,b,c,d);
}
iii) #include <stdio.h>
void main() {
int n1 = 10, n2 = 6, res;
res = n1 + (~ n2 + 1) ;
printf ("Result is : %d", res);
}
Question 1c) What is the correct order of evaluation of operators for the expression: [1]
“z = x + y * z / 4 % 2 – 1”.
Question 1d) Convert the following numbers into required form [3]
A. (11101.110011)2 = (?)16
B. (f2.A)16 = (?)10
C. (29.8)10 = (?)16
Page 1 of 2
Question 2a) Find the result of given 2’s complement binary Addition/Subtraction. [2]
The result must be shown in binary as well as decimal form also.
i) (1100 1010)2 – (1001 1010)2
ii) (0000 0010)2 – (0000 1000)2
Slab Tax
Slab1: Income between Rs 0 to no income tax is charged
1,00,000
Slab2: Income between Rs 1,00,001 to tax rate of 10% is charged
5,00,000
Slab3: Income above Rs 5,00,001 tax rate of 20% is charged
Addition to above surcharge of 1.2% is added on calculated tax for all slabs for “education and clean India”
campaign.
(Your program must have a main function, at least one user function and at least one macro statement. You can take
input from user for as many parameters you think are required for this program. Readability of code with proper
names, comments will be considered while evaluating answer.)
An electricity board charges the following rates for the use of electricity:
For the first 200 units; 80 P per unit
For the next 100 units; 90 P per unit
Beyond 300 units; Rs. 1 per unit
All users are charged a minimum of Rs. 100 as meter charge. If the total amount is more than Rs. 400,
then an additional surcharge of 15% of total amount is charged.
Write a program to read the names of users and number of units consumed and printout the charges with
names.
XXXXXX
Page 2 of 2