New CTS Sample Question

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

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:

It is 1 –indexed based iteration

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

3) reduce the fraction

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.

Write a program to help ram

Input format:

First line contains single integer that denotes the numerator

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.

If numerator is less than denominator, the output is “numerator” (slash)/”denominator”

If numerator is zero just print 0

If denominator is zero print invalid

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

The person contradict mary’s belief if one of the following is true.

They are young and beautiful but not loved

They are loved but not young or not beautiful

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:

Young beautiful loved

No

Sample input 2:

Sample output 2:

Not young Not beautiful loved

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

Note: if the two matrix cannot be added print invalid.

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:

Maximum number of piles are needed

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]

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy