ACP Lab Session 6 Questions-1

You might also like

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

21PC04 / 21FC04 / 21DC04 / 21SC04 / 21YC04 / 21LC04 / 21EC04 / 21TC04

&
ADVANCED C PROGRAMMING
Lab Session - 6

S. No Questions
1 John is novice in programming. He learned how to generate a fibonacci series. He noticed that there are
even numbers in fibonacci series. Now, John wants to find the Nth even number in the fibonacci series.
Write a C program to help John to solve this problem.

Input Format: Take N value to find that Nth even number in fibonacci series.
Output Format: Print the Nth even number in the fibonacci series.
Constraints : 1 ≤ N ≤ 30

Example:
Input:4
Output:144

2 Given an alphanumeric string made up of digits and lower case Latin characters only, find the sum of
all the digit characters in the string.

Input
The first line of the input contains an integer T denoting the number of test cases. Then T test cases
follow.
Each test case is described with a single line containing a string S, the alphanumeric string.
Output
For each test case, output a single line containing the sum of all the digit characters in that string.
Constraints
1 ≤ T ≤ 1000
1 ≤ |S| ≤ 1000, where |S| is the length of the string S.

Input: Output:
1 7
ab1231da

3 Snow Howler is the librarian at the central library of the city of HuskyLand. He must handle
requests which come in the following forms:

1 x y: Insert a book with y pages at the end of the xth shelf.

2 x y: Print the number of pages in the yth book on the xth shelf.

3 x: Print the number of books on the xth shelf.

Input Format:
In the first line integer total_number_of_shelves i.e the number of shelves in the library is
given. Similarly in the second line integer total_number_of_queries i.e, the number of requests
is given. Each total_number_of_queries contains a request in one of the three specified formats.

Constraints:
1 <= total_number_of_shelves <= 10^5.
1 <= total_number_of_queries <= 10^5.
For the queries of the 2nd type, it is guaranteed that the book is present on the xth shelf at the
yth index.
0 <= x <total_number_of_shelves.
Numbers for both books and shelves are starting from 0.
The maximum no of books per shelf <= 1100.

Output Format:
Write a C program for all the requests of type 1, 2 and 3.

Sample Input 1: Sample Output 1:


5 78
5 2
1 0 15
1 0 20
1 2 78
220
30

You might also like