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


Second Semester 2013-2014
Mid-Semester Test
(EC-2 Regular)
Course No.
Course Title
Nature of Exam
Weightage
Duration
Date of Exam
Note:
1.
2.
3.

: TA ZC164
: COMPUTER PROGRAMMING
: Closed Book
: 35%
: 2 Hours
: 16/02/2014 (FN)

No. of Pages
=2
No. of Questions = 5

Please follow all the Instructions to Candidates given on the cover page of the answer book.
All parts of a question should be answered consecutively. Each answer should start from a fresh page.
Assumptions made if any, should be stated clearly at the beginning of your answer.

Q.1. Assume that array array1 is defined as shown.


array1 =

(a)
(b)
(c)
(d)
(e)
(f)

1.1
0.0
2.1
-1.4

0.0
-3.0
0.3
5.1

-2.1
-5.6
0.1
0.0

-3.5
2.8
-0.4
1.1

6.0
4.3
1.3
-3.0

array1(3,:)
array1(:,3)
array1(1:2:3, [3 3 4])
array1([1 2],:)
size(array1([1 2],:))
length(array1(1:2:3, [3 3 4]))

[6]

Q.2. The cost of sending a package by an express delivery service is 15.00 rupees for the first
two kilos and 5.00 rupees for each kilos or fraction thereof over two kilos. If the package
weighs over 70 kilos, a 15.00 Rupees excess weight surcharge is added to the cost. No
package over 100 kilos will be accepted. Write a program that accepts the weight of the
package in kilos and computes the cost of posting the package.
[6]
Q.3. Assume a, b, c and d are defined as follows.

Calculate the results of the following operations if they are legal


(a)
(b)
(c)
(d)

result = a * [c c]
result = a .* [c c]
result= (a + b) * c
result = a + b .* c

TA ZC164 (EC-2 Regular)


Page 1 of 2

[6]

Second Semester 2013-2014

TA ZC164 (EC-2 Regular)

Second Semester 2013-2014

Page 2

Q.4. Evaluate the following matlab expressions and provide the results as the matlab reports.
(a)
5 >= 5.5
(b)
true > false
(c)
17.5 && (3.3 > 2).
(d)
20 > 20
(e)
~~ ( 35/17) ==(35/17)
(f)
true | false
[6]
Q.5. The nth Fibonacci number f(n)is defined as follows.
f(1) =1
f(2) = 2
f(n) = f( n-1) + f(n-2)
Therefore the third Fibonacci number is f(3) = f(2) + f(1) = 3. Similarly for any n, f(n)
can be computed. Write an algorithm for the for the problem of computing nth
Fibonacci number f(n) given n. Draw the flowchart as well. Write a matlab function
fact(n) to solve this problem.
[11]

**********

TA ZC164 (EC-2 Regular)


Page 2 of 2

Second Semester 2013-2014

You might also like