Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Birla Institute of Technology & Science, Pilani

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Birla Institute of Technology & Science, Pilani

Work Integrated Learning Programmes Division


M. Tech. Software Engineering at Wipro Technologies (WASE)
Second Semester 2015 - 2016
Mid-Semester Exam (Regular)

Course Number : SEWP ZC142


Course Title : Computer Programming No. of Pages : 2
Type of Exam : Closed Book No. of Questions : 3
Weightage : 30%
Duration : 2 hours
Date of Exam : May 08, 2016 Session : AN(12.30
No. of Questions : 24 to 2 PM)
--------------------------------------------------------------------------------------------------------------------
-Note: Please read and follow all the instructions given on the cover page of the answer script.
There are 3 questions. Start each answer from a fresh page. All parts of a question should be
answered consecutively. Appropriate assumptions can be made and explicitly mentioned.

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

Question 2b) Develop an algorithm for the following problem. [3]


Find total tax to be paid if the input is total income for following problem statement
Income Tax is charged based on total income of the person from all sources (like Salary, bank interest,
house rent etc.). Tax rate varies based on income amount. Assume the currently slabs in place are:

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.

Question 2c) Develop a Flowchart for the following problem. [3]


Depict the logic for computing the value of xy (x to the power y) taking x and y as inputs.

Question 3a) Write a program for the following problem. [4]


Write a program to check if a given Integer is Power of 2 using Bitwise Operators

(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.)

Question 3b) Write a program for the following problem. [4]

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.

Question 3c) Write a program for the following problem. [4]


Write a C program to convert binary number to decimal number with comments on appropriate statements.
Input – 4 bit binary number, Output – Equivalent decimal number.

XXXXXX

Page 2 of 2

You might also like