CTSD Lab Exam-1 Questions

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

QUESTION-01

A. Your local library needs your help! Given the expected and actual return dates fora
library book, create a program that calculates the fine (if any). The fee structureis as
follows: a. If the book is returned on or before the expected return date, no fine will be
charged (i.e., Fine=0) b. If the book is returned after the expected return day but still
within the same calendar month and year as the expected return date, fine=
15Hackos*(the number of days late) c. If the book is returned after the expected return
month but still within the samecalendar year as the expected return date, fine=500
Hackos*(the number ofmonths late) d. If the book is returned after the calendar year
in which it was expected, there isa fixed fine of 10000 Hackos.
B. Gopal likes problems solving. If he solves one problem on first day, on second day he
solves two more than first day’s count and so on. Find the number of problems solved
on the nth day. If he takes p minutes to solve each problem, find the total hours he spent
on problem solving in that month.

QUESTION-02
A. A painter wants to paint the outer surface of an oil rectangular can. The dimensions
of the can are 20cm x 15cm x 12cm(l,b,h). If 5 paisa is charged to paint per square
centimetre, Find the cost of painting in rupees.
B. The Fibonacci numbers, commonly denoted F(n) form a sequence, called the
Fibonacci sequence, such that each numberis the sum of the two preceding ones,
starting from 0 and 1. That is, F (0) = 0, F (1) = 1 F(n) = F (n - 1) + F (n - 2), for n > 1.
Given n, calculate F(n). Now your task to print the Fibonacci series number’s up to n
number.

QUESTION-03
A. Hari wants to construct a staircases pattern using the ′#’ symbol. He is very busy at
CRT training. Your task is to help Hari to print staircase pattern.
B. On the eve of Diwali, Hari is decorating his house with a serial light bulb set. The
serial light bulb set has N bulbs placed sequentially on a string which is programmed
to change patterns every second. If at least one bulb in the set is on at any given instant
of time, how many different patterns of light can the serial light bulb set produce? Note:
Lighting two bulbs *-* is different from **-

QUESTION-04
A. Anuj takes a loan of Rs.7,00,000 to pay his B.Tech fees from his friend at 12.5% rate
of interest. He needs to clear the duesto get the No Objection Certificate. Help him in
finding out the amount to be paid with interest to the bank. Interest is computed using
Simple Interest for a period of 4 Years. Pass inputs as parameters to a function named
Simple_Interest which will return the interest to the main function.
B. Implement pow(x, n), which calculates x raised to the power n (i.e., x^n).
QUESTION-05
A. Shiva is the youngest programmer in the world, he is just 12 years old. Shiva is
learning programming and today he is writing his first program. The task is very
simple: given two integers A and B, write a program to add and multiply these two
numbers and output it.
B. Juliet is the college topper, so she has given a challenge to Romeo. The challenge is
to print the given star pattern.Your task is to help Romeo to successfully print the given
star pattern.

QUESTION-06
A. Jack is a talkative student in the class. His teacher wants to make him busy by
assigning some work. So, she asks him to consider two variables and interchange the
values of the variables. The teacher instructs him not to use any temporary variables
and to perform the task using pointers only. Help Jack in Completing the task.
B. Consider a closed circuit containing ten resistors connected in series with
resistances 10, 12, 13, 22, 34, 44, 45, 5, 55, 7 respectively. Write the resistances to a file
named res.txt and find the average resistance of the circuit.

QUESTION-07
A. Six friends go on a trip and are looking for accommodation. After looking for hours,
they find a hotel which offers two types of rooms — double rooms and triple rooms. A
double room costs Rs. X, while a triple room costs Rs. Y. The friends can either get three
double rooms or get two triple rooms. Find the minimum amount they will have to pay
to accommodate all six of them.
B. Ramu has reached the finals of the Annual Inter-school Declamation contest. For the
finals, students were askedto prepare 10 topics. However, Ramu was only able to
prepare three topics, numbered A, B and C — he is totally blank about the other topics.
This means Ramu can only win the contest if he gets the topics A, B or C to speak
about.On the contest day, Ramu gets topic X. Determine whether Ramu has any chances
of winning the competition. Print "Yes" if it is possible for Ramu to win the contest, else
print "No".[Use Ternary Operator]

QUESTION-08
A. Mark, Bob and Jack are bidding for an artifact at an auction. Mark bids A rupees, Bob
bids B rupees, and Jack bids C rupees (where A, B, and C are distinct). According to the
rules of the auction, the person who bids the highest amount will win the auction.
Determine who will win the auction.
B. In a Kinder Garden Miss. Pricilla is teaching her little students to identify the
alphabets and trying to teach the differentiation of vowels and consonants. Help the
students to identify whether the displayed character is a vowel or consonant. (Use
switch-case)
QUESTION-09
A. Mr. Ravi has prepared test-1 question paper for 1st year B.Tech. The test consists of
3 questions with each question having certain marks assigned to it. However, Mr.Ravi
has assigned distinct marks for each of 3 questions. This means no two questions can
have the same marks. Find the minimum and maximum marks that he has set the paper
for. Solve this problem using arrays by declaring the array globally.
B. Given a base-10 integer, n, convert it to binary (base-2). Then find and print the base-
10 integer denoting the maximum number of consecutive 1's in n's binary
representation. When working with different bases, it is common to show the base as
a subscript.

QUESTION-10
A. Alice was trying to analyze if the number is even or odd, and then if it is even,
whether it is
divisible by 4 or not,and if it is odd, whether it is divisible by 3 or not. Your task is to
help Alice.
Write a C program to perform this task using nested if.. else
B. Google is recruiting software engineers to calculate distance between the co-
ordinates of two buildings in Google Maps. Some buildings do not have coordinates but
have distances to the nearest buildings. If the co-ordinates of two buildings are - A is
(1,1), B is (2,3) and building C is 2kms away from building B. Find the length of the path
from A to C via B.

QUESTION-11
A. Chef's coding class is very famous in Chef land. This year X students joined his class
and each student will require one chair to sit on. Chef already has Y chairs in his class.
Determine the minimum number of new chairs Chef must buy so that every student is
able to get one chair to sit on.
B. Assume a hall with the capacity of n seats. Every occupied seat is represented with
1 and the empty seat with 0. Rahul was asked to code to count the total number of
occupied and empty seats. Help Rahul to write a C program to perform this task.

QUESTION-12
A. It's the sale season and Raghu bought items worth a total of X rupees. The sale season
offer is as follows: l if X≤100, no discount. l if 100 < X ≤1000, discount is 25 rupees. l if
1000 < X ≤5000, discount is 100 rupees. l if X > 5000, discount is 500 rupees. Find the
final amount Raghu needs to pay for his shopping
B. Manisha works in a supermarket in billing counter. A customer bought 10 pens and
5 chocolates. Each pen costs Rs.1.5 and each chocolate costs Rs.10. By using functions
help Manisha to calculate the total bill amount and remaining change to be returned if
the customer pays Rs. 100.

You might also like