New CTS Sample Question
New CTS Sample Question
New CTS Sample Question
1)group multiplication:
Given array of integers of size n and k value. Write a pgm to modify the array based on following
condition
1)split the array into groups each of size k and if the size of the last group is less than k, leave the
group as it is.
2)each element of the group is multiplied with the kth element and leave the kth element as it is
NOTE:
Input format:
First line contains single integer that denotes the size of the array
The Second line contains space separated integers values of the array
The third line contains a single integer that denotes the value of k.
Output format:
Output is a series of integers separated by space that denotes the array values.
SAMPLE INPUT 1:
10
1 2 3 4 5 6 7 8 9 10
SAMPLE OUTPUT 1:
3 6 3 24 30 6 63 72 9 10
EXPLANATION:
1)for first element [1 2 3] kth element is 3. So multiply 3 with each of the numbers in the array
Before the kth element and leave the kth element as it is. The 1 st set of number in the array would
look like [3 6 3]
2)for the second element [4 5 6 ] kth element is 6.so multiply 6 with each of the numbers in the
array before the kth element and leave the kth element as it is .the second set of numbers in the
array would look like [24 30 6].
3) for the third element [7 8 9 ] kth element is 9.so multiply 9 with each of the numbers in the array
before the kth element and leave the kth element as it is .the third set of numbers in the array
would look like [63 72 9].
4)for first iteration you have only one number which is less than size of k.so leave the number as it is
SAMPLE INPUT 2:
4
5 6 14 5
SAMPLE OUTPUT 2:
30 6 70 5
2)The recruitment
Candidates apply for the vacant position in ABC company. Each candidate having his/her own
proficiency level (pl) which is represented as positive integer. Higher the proficiency level better his
the chance of recruitment
There are only n places in the team and the recruiter hires only those who have their pl. greater than
or equal to m.
All applicants are standing in a queue and if the current once satisfy the required condition , he is
taken into a team right away. Once the team is full all the remaining people are denied. Regardess of
their pl.
write a program to find the total pl of the applicants who get hired?
Input format:
First line contains single integer that denotes the size of the array
The Second line contains space separated integers values of the array
The third line contains a single integer that denotes the value of n.
The fourth line contains a single integer that denotes the value of m.
Output format:
A single integer value that denotes the total pl of applicants who get hired
Sample input1:
31213
Sample output 1:
Explanation:
The first applicant of the third applicant get selected with pl 3 and 2, respectively and total is 5.
Sample input 2:
4236254
Sample output 2:
15
Ram is a 4th grade kid studying in ABC international school, his maths teacher has given him
assignment on fraction. Give a fraction ,find the reduced form of that particular fraction.
Input format:
The Second line contains single integer that denotes the denominator.
Output format:
If answer is whole number that output is a single integer that denotes the whole number.
It answer is mixed fraction after reducing the output is “whole number” space “numerator”
(slash)/”denominator” refer samples for more clarity.
Sample input 1:
11
Sample output 1:
12/9
Sample input 2:
Sample output 2:
2
Sample input 3:
Sample output 3:
1/3
Sample input 4:
Sample output 4:
Sample input 5:
Sample output 5:
Invaild.
4) mary”s belief
Once many year a famous song , and the line from it stuck in her head . that line was “will you still
love me when I am no longer young and beautiful?” . mary beliefs that a person is loved if and only if
he /she is both young and beautiful . but it is quite a depressing thought , so she wants to put her
belief to the test
Knowing whether a person is young, beautiful and loved , write a program to find out if they
contradict mary’s belief
Input format:
First line contains single integer that denotes the whether the person is young ( 1-young, 0-not
young)
The Second line contains single integer that denotes the whether the person is beautiful ( 1-
beautiful, 0-not beautiful)
The third line contains a single integer that denotes the whether the person is loved( 1-loved, 0-not
loved)
Output format:
Print the person type in the first line and print whether it contradict or not in the second line.
Sample input1:
Sample output:
No
Sample input 2:
Sample output 2:
Yes
5)teaching maths
Ankit is teaching maths to the two 9 th class students vinay and sanjit . he is trying to explain the
theory of matrices , which is the collection of element which is arranged in rows and columns . ankit
gives one matrix each to both of them and ask them to add the respective elements of the matrices
then he explains that the resultant matrix is called the sum of the two matrix After adding the
respective element of the matrices .
Write a program to help vinay and sanjit to find the sum of the two matrix
Input format:
First line contains single integer that denotes the row size of the first matrix (m1)
The next line contains single integer that denotes the column size of the first matrix (n1)
The next “m1” line denotes the matrix row , with each line containing space separated integer to the
first matrix.
The next line contains the single integer denote the row size of the second matrix (m2)
The next line contains single integer that denotes the column size of the second matrix (n2)
The next “m2” line denotes the matrix row , with each line containing space separated integer to the
second matrix
Output format:
Each line denotes the sum of matrix & row, each line containing space separated integer of the sum
of matrix
Sample Input 1:
100
400
033
123
986
340
Sample output 1:
223
13 8 6
373
6) pile of boxes
(The pile of boxes can be constructed by placing boxes one on top of the other forming a vertical
column. It is not possible to place more than one box on the top of another one directly) each box
has a strength value – the number of boxes that it can hold without collapsing
Write a pgm to calculate the minimal number of piles that need to be constructed to use up all of
these boxes.
Input format:
1st line contains a single integer value that denotes the number of boxes
2nd line contains line containing space separated integer values that denotes the strength of each
box
Output format:
Sample input 1:
31213
Sample output 1:
Sample input 2:
431100
Sample output 2:
Explaination :
For [4 3 1 1 0 0 ] the output should be 2.it is possible to construct two piles[4,3,1,0] and [1,0]