You are on page 1of 5

Candidate’s Profile

Name:
Email Id:
Mobile No:
Skill Sets:

Name of the College and Branch: Ycp Mumbai PG-DAC

Feedback / Remarks / Any Referrals:

Programming Test

This paper has been designed to test your programming abilities – it is meant to be
a starting point for further discussion and provides you an opportunity to
highlight your skills. You can take the test in the programming language of your
choice. Your code doesn’t have to compile exactly but it should be reasonably close
(pseudo-code is not OK).

If you are unsure about something, or make an assumption, write the assumption as
part of your answer. Good luck ☺

A-1: Implement the below function to print the count of numeric characters (0-9) in
a given string and also print the count of remaining characters. (Ignore the
character cases, it can be lower or upper case)

The function will take 1 parameter which will be a String (or a character array).
You do not have to write code to get the input parameter from the user.

int frequencyOfNumericChars(String input) {


// TODO: Add code here
}

Example:
Input: raja1123labs Output:=’1’=2, ‘2’=1, ‘3’=1, others=8
Input: Buffet101 Output: ‘1’=2, ‘0’=1, others=6
A-2: Write a function that takes an input parameter as a String. The function
should replace the alternate words in it with “xyz” and print it. Words are
separated by dots. (Avoid using inbuilt functions)

If input is “i.like.this.program.very.much”
Output will be “i.xyz.this.xyz.very.xyz”

A-3: Write a function that takes an array of integers as input and prints the
second-maximum difference between any two elements from an array.

Example:
int arr[]={14, 12, 70, 15, 95, 65, 22, 30};
First max-difference = 95-12=83
Second max-difference = 95 -14 = 81
So output should be 81

A-4: Write a function that takes input as an integer number and prints the closest
prime integer to that
number. The closest prime can be greater or smaller than the passed input integer.
If there are equi-
distant prime-numbers, print both.
Example:
Input#1: 32
Output#1: 31
Input#2: 30
Output#2: 29 31
A-5: Variation of Fibonacci
The Fibonacci sequence is constructed by adding the last two numbers of the
sequence so far to get the next number in the sequence. The first and the second
numbers of the sequence are defined as 0 and 1. We get:
0, 1, 1, 2, 3, 5, 8, 13, 21…

Write a function which takes input as a number:


If the given number is a Fibonacci number, print the number
If the given number is NOT a Fibonacci number, print the sum of all Fibonacci
numbers less than the given number.

int getFibOutput(int input) {


// TODO:
}

Example
(21 is a Fibonacci number)
Input: 21 Output: 21
(20 is NOT a Fibonacci number so, output is 10 (13+8+5+3+2+1+1))
Input: 20 Output: 33

You might also like