Cognizant Probable Sample Questions 2

You might also like

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

1.

Problem Statement :
2. You’re given a string where multiple characters are repeated consecutively. You’re
supposed to reduce the size of this string using mathematical logic given as in the example
below :
Input :
aabbbbeeeeffggg
Output:
a2b4e4f2g3
Input :
abbccccc
Output:
ab2c5
C++
JAVA
Python
C++
3. Problem Statement :

You are given an array of length “len” ,another item called k and an integer value x. Your
job is to find the sum of k farthest items in the array from x.

First line has len, k and x respectively


2nd line has the array
Example :
Input :
5 3 20
21 4 15 17 11
Output :
30

4, 15 and 11 are farthest from 20. Thus, their sum will be the answer.

C++
JAVA
Python
C++
4. Problem Statement :
Write a program to find the nth largest and nth smallest item in the array and print them
in the same line.
Input Format
The first line has the following –
Size of array, value of n
2nd line has the array
Output Format
Nth largest and nth smallest respectively
Input : Output :
63 34
123456
C++
JAVA
Python
C++
5. Problem Statement :
Write a function to solve the following equation :
a3 + a2b + 2a2b + 2ab2 + ab2 + b3.
Write a program to accept three values in order of a, b and c and get the result of the
above equation.
C++
JAVA
Python
C++
6. Problem Statement :
In the city, there are a bunch of dealerships who sell bikes & cars. A function is there
which tells how many dealerships there are and the total number of cars in each
dealership.

Your job is to calculate how many tyres would be there in each dealership.

If you are using the predefined function use this structure,


Struct dealership {
Int cars;
Int bikes;
}
Input : Output :
3 20
42 16
40 8
12
Explanation :
1. There are total 3 dealerships
2. Dealerships1 contains 4 cars and 2 bikes
3. Dealerships2 contains 4 cars and 0 bikes
4. Dealerships3 contains 1 cars and 2 bikes
5. Total number of tyres in dealerships1 is (4 x 4) + (2 x 2) = 20
6. Total number of tyres in dealerships2 is (4 x 4) + (0 x 2) = 16
7. Total number of tyres in dealerships3 is (1 x 4) + (2 x 2) = 8
C++
JAVA
Python
C++
7. Explain Calloc vs Malloc with example
8. Explain different kinds of communication systems, the common challenges and how to
face them
9. Write an algorithm to search an element in circular linked list and also tell its advantage
over SLL.
10. X+Y+Z=30
You have to make this equation true using the numbers 1,3,5,7,9,11,13,15 any number of
times.
11. (a-n)(b-n)(c-n)……………………………………….(y-n)(z-n)=? What will be the output?
12. What are the components of Data Structure ?
13. What are SDLC phases?
14. State dynamic/restrictive/static typecasting :
15. What is Object slicing?
16. What are the components of C language?
17. What are the advantages of DBMS over traditional file-based systems?
18. What is the difference between primary key and unique constraints?
19. What is database normalization?
20. Why is the use of DBMS recommended? Explain by listing some of its major advantages?
21. What are the differences between DDL, DML, and DCL in SQL?

You might also like