# Cognizant Interview Questions

Cognizant is a multinational corporation that provides IT services to different organizations, including digital technology, consulting, operations and all kind of services. It is headquartered in **Teaneck, New Jersey, United States**. It was founded as in-house technology unit of **Dun & Bradstreet in 1994** and started serving external organizations as clients in 1996.

It offers the unique learning and work environment with their great learning materials.

Cognizant provides an intelligent, digital and tactical approach that transforms the way business gets done without interrupting business as usual. Services provided by Cognizant are like information technology, information security, consulting, ITO and BPO services. These include business & technology consulting, systems integration, application development & maintenance, IT infrastructure services, analytics, business intelligence, data warehousing, customer relationship management, engineering & manufacturing solutions, research, and development outsourcing, and testing solutions.

Cognizant has many branches in all over the India as well as outside India.

## Cognizant recruits its employees in two ways:

### 1. On-campus Recruitment

- Aptitude
- Programming
- HR

### 2. Off-campus Recruitment

- Aptitude
- Programmin

## Cognizant Interview Pattern for On-campus drives:

### 1. Logical Reasoning

- Questions – 14
- Time – 14 minutes
- Difficulty – High
- Cut-Off – 70%

### 2. Quantitative Aptitude

- Questions – 16
- Time – 16 minutes
- Difficulty – Medium
- Cut-Off – 70%

### 3. Verbal Ability

- Questions – 25
- Time – 25 minutes
- Difficulty – Medium
- Cut-Off – 70%

### 4. Automata Fix

- Questions – 7
- Time – 20 minutes
- Difficulty – High
- Cut-Off – 70%

## Cognizant Interview Pattern for Off-campus drives:

### 1. Aptitude Questions

- Questions – 16
- Time – 16 minutes
- Difficulty – High
- Cut-Off – 70%

### 2. Logical Questions

- Questions – 14
- Time – 14 minutes
- Difficulty – Medium
- Cut-Off – 70%

### 3. English Questions

- Questions – 25
- Time – 25 minutes
- Difficulty – Medium
- Cut-Off – 70%

### 4. Coding Questions

- Questions – 2
- Time – 60 minutes
- Difficulty – Medium
- Cut-Off – 70%

## Cognizant First Round

## Aptitude & Logical Questions

## 1) The product of 2 numbers is 2028, and the H.C.F. is 13. The number of such pairs is:

- 3
- 2
- 6
- 9

**Answer:** b

**Solution:**

Let the numbers 13a and 13b.

Then, 13a x 13b = 2028

=> a * b = 12.

Now, the co-primes with the product 12 are (1, 12) and (3, 4). So, the required numbers is (13 x 1, 13 x 12) and (13 x 3, 13 x 4).There are two such pairs

## 2) Find the biggest digit which on dividing 1657 and 2037 leaves the remainders 6 and 5 respectively is:

- 156
- 127
- 135
- 115

**Answer:** b

**Solution:**

The number we require = H.C.F. of (1657 – 6), (2037 – 5) =H.C.F. of 1651 and 2032 = 127.

## 3) The L.C.M of 2 numbers is 495, and the H.C.F is 5. If the sum of these numbers is 100, then their difference is,

- 10
- 46
- 70
- 90

**Answer:** a

**Solution:**

Let the numbers be x and (100-x).

Then, x*(100-x) = 5*495-100-x = 5*495

x2-100x+2475=0x2-100x+2475 = 0

(x – 55)*(x – 45) = 0

x = 55 or x = 45

The numbers are 45 and 55

Required difference = (55-45) = 10.

## 4) H.C.F and L.C.M of two numbers are 84 and 21 respectively. If the ratio of the two numbers is 1:4, then the larger of the two numbers is

- 12
- 48
- 84
- 108

**Answer:** c

**Solution:**

Let the numbers be x and 4x. Then, x×4x=84×21 ?

x2=84×214? x=21x×4x=84×21 ? x2=84×214? x=21

Hence Larger Number = 4x = 84.

## 5) The smallest number is given which is a perfect square and contains 7936 as a factor is:

- 251664
- 231564
- 246016
- 346016

**Answer:** c

**Solution:**

7936 => 2^2 * 2^2 * 2^2 * 2^2 * 31^1

To make it as a perfect square, we have to multiply

7936 with 31….

Hence the read no. is 7936*31 = 246016.

## 6) P is an integer. P is greater than 994. If P -7 is a multiple of 11, then the largest number that will always divide (P+4)(P+15) is

- 242
- 343
- 321
- none

**Answer:** a

**Solution:**

p-7= 11*a (as it is multiple of 11)

p=11*(a+7)

So (p+4)*(p+15) = (11a+7+4)*(11a+7+15);

= (11a+11)*(11a+22);

=11*11(a+1)*(a+2);

=121*2

=242

## 7) The greatest number that will divide 65, 134 and 224 to leave the same remainder in each case:

- 3
- 7
- 5
- 9

**Answer:** a

**Solution:**

The greatest number = H.C.F of (134-65), (224-134),

(224-65)

H.C.F of 69, 90 and 159 = 3.

15 is the greatest number.

## 8) What is the smallest four-digit number which when divided by 6, leaves a remainder of 4 and when divided by 4 leaves a remainder of 3?

- 1043
- 1073
- 1103
- None of these

**Answer:** d

**Solution:**

remainder when m is divided by 4 = 2

Smallest m is 2.

Hence, N = 1001 + 6 * 2 = 1013.

## 9) Sum of money given to a man at compound interest doubles itself within six years. In how much time will it amount to eight times itself?

- 16
- 24
- 18
- 20

**Answer:** c

**Explanation:**

1st year = 100, 6th year = 200, 12th year = 400, 18th year = 800.

## 10) A set sum of money amounts to Rs.1500 in 2 years and Rs. 1726 in 4 years. Find the sum

- Rs850, 10%
- Rs900, 12%
- Rs800, 13%
- Rs1274, 15%

**Answer:** d

**Solution:**

1726-1500= 226 for 2 years (4-2) so for one year 226/2= 113 then for 2 years interest is 113+113=226 Then principal 1500-226=1274. Now 113/1274*100= 15%.

## 11) Mina drives from her home to the nearest bus station at an average speed of 80km/h. From the bus station, she boards a bus that takes to her office at a speed of 120km/h. The entire distance covered by her is 92km, and the entire journey took her 1 hour. Find the distance between the bus station from where she boards the bus and her office.

- 91.97
- 94.65
- 83.97
- 92.78

**Answer:** a

**Explanation:**

Let from her home to station distance = X, so,

(X 80) + ((92-X)/120) = 1

Solving this X = 183.97 km

So from office to station = 183.97-92 = 91.975 km

## 12) Straight line between 2 places is 3000m. A person moves with 6/11km/hour from p to q @12pm and another person moves from opposite direction with speed 5/22km/hour from q to p @ 1pm.when they will meet together?

- 4.18pm
- 4.17pm
- 8.15am
- 9.10pm

**Answer:** b

**Solution:**

The person from p moves 6/11 km in 1 hour so 3-6/11=27/11

6/11 t+5/22 t=27/11

17/22 t=27/11

t=54/17 =3.17hso, time=4:17 pm

## 13) A 270-meter long train running at the speed of 120 km/h crosses the second train running in the opposite direction with the speed of 80 km/h in 9 seconds. What is the length of the second train?

- 360meter
- 260meter
- 270meter
- 230meter

**Answer:** d

**Solution:**

train running in the opposite than total speed= (80+120) = 200 km/h

200kmph=200*5/18=500/9 m/set the length of another train is l meter than

(270+l)/9=500/9

Length (l) =230 meter.

## 14) How many seconds will a 500-meter long train moving with a speed of 63 km/hour, take to cross a man walking at a speed of 3 km/hour in the direction of the train?

- 42
- 50
- 30
- 28

**Answer:** c

**Solution:**

train and man is moving in the same direction so the relative speed will be = (63-3) km/hour = 60 km/hour

Then 60 km/hour * 5/18= 50/3 m/sec

Therefore, time = distance/speed

= 500/ (50/3)

= 30 seconds

So the answer is 30 seconds.

## 15) If ax = by, then:

- log(a/b) = x/y
- log(a) / log(b) = x/y
- log(a) / log(b) = y/x
- None of these

**Answer:** c

## 16) If log x + log y = log (x + y), then:

- x = y
- x*y=1
- y = (x-1)/x
- y = x/(x-1)

**Answer:** d

**Solution:**

log x + log y = log (x + y)

log(x*y) = log (x + y)*x*y = x + y

x*y – y = x

(x – 1)*y = x, y = x/(x-1).

## 17) If 0.5(log a + log b) = log{(a + b)/3}, then define the relation between a and b is:

- a2+b2 = 7ab
- a2-b2 = 7ab
- (a + b)2 = 2
- (a + b)/3 = (1/2)(a +b)

**Answer:** a

**Solution:**

0.5[log(a) + log(b)] = Log[(a + b)/3]

0.5*log(a*b) = log[(a + b)/3]

log[sqrt(a*b)] = log[(a + b)/3]

sqrt(a*b) = (a + b)/3

3*sqrt(a(b) = a + b

9 *a*b = a^2 + 2ab + b^2

7*a*b = a^2 + b^2

## 18) If log x = log 3 + 2 log 2- (3/4) log 16. The value of x is:

- ½
- 1
- 3/2
- 2

**Answer:** c

**Solution:**

log x= log 3+ 2 log 2 – (3/4)log 16.

log x = log 3 + 2 log 2 – (3/4) log 2^4.

log x = log 3 + 2 log 2 – (3*4)/4 log 2.

log x = log 3 + 2 log 2 – 3 log 2.

log x = log 3 – log 2.

log x = log 3/2.

So, x = 3/2.

## 19) If log x = (1/2) log y = (1/5) log z, the value of x4y3z-2 is:

- 0
- 8
- 1
- 5

**Answer:** c

**Solution:**

log(x) = (1/2) log(y) => y = x^2

log(x) = (1/5) log(z) => z = x^5

Then x^4*y^5*z^-2 = x^4*x^6*x^-10 = x^10 * x^-10 = x^0 = 1,

If any value has power value as 0 then its overall value is 1.

## 20) If log10000 x = -1/4, then x is given by:

- 1/100
- 1/10
- 1/20
- none of these

**Answer:** b

**Solution:**

Log10000^x = -1/4

X= (10000)-1/4

10-1 = 1/10.

## 21) A men can do a job within 10 days, working 8 hours a day, if women are 33.33% more efficient than the men. How many women will it take to finish the same job in 10days working 6 hours a day?

- 10
- 12
- 15
- 16
- 20

**Answer:** e

**Solution:**

By using formula 🙁 M1D1H1/W1)=(M2D2H2/W2)

(20*10*8/133.33)=(M2*10*6/100)

M2=20.

## 22) How many 5 digit no. can be formed from 0,2,4,5 & 9?

- 95
- 96
- 120
- 125

**Answer:** b

**Solution:**

5!-4!

We can arrange those five letters in 5! Way, and If 0 comes at the ten thousand places, it will not be a five digit number. So the possibility of getting 0 at the 1st place is 4! Ways. So we need to subtract this 4! From the 5!.

## 23) What will be the most significant number which divides 37, 59 and 74 leaving remainder 2, 3 and 4 respectively?

- 9
- 2
- 4
- 7

**Answer:** d

**Solution:**

Let, divisor = X.

Dividend = (Divisor × Quotient) + Reminder

Therefor,

37 = (X × Q1) + 2

(X × Q1) = 35 [Where Q1 is a quotient]

Likewise,

(X × Q2) + 3 = 59

56 = (X × Q2) [Q2 = quotient]

(X × Q3) + 4 = 74

70 = (X × Q3)[Q3 = quotient]

Now, since X is the Biggest digit satisfying the given condition, X will be the HCF of 35, 56 and 70.

HCF [35, 56, 70] = 7

Largest number is 7.

## 24) The number of times four used while writing the numbers from 1 to 100 is:

- 18
- 17
- 21
- 19

**Answer:** d

**Solution:**

In the unit’s place, starting with 4, 14 ….94, we have nine times 4s used.

Also in 40 – 49, we have 2, ten times in the ten’s place.

Hence, total no. of 2s used = 9 + 10 = 19

## 25) Sum of two numbers is 60, and their product is 120. What is the sum of their reciprocals?

- 3
- 1
- 1/2
- 1/3

**Answer:** c

**Solution:**

Given, a + b = 40 and a*b = 120.

Sum of their reciprocals:

1/a+1/b = (a + b)/a*b= 40/120 =1/2.

## 26) If 13 + 23 + 33 +…. + 103 = 4050, then find the value of 23 + 43 + 63 + …. + 203.

- 32400
- 80075
- 13100
- 54100

**Answer:** a

**Solution:**

Given, 13 + 23 + 33 +…. + 103 = 4050

23 + 43 + 63 + …. + 203

= 23 (13 + 23 + 33 +…. + 103)

= 8 × 4050

= 32400.

## 27) In an exam, 30% of the candidates failed in Science and 45% in History. If 20% failed in both Science and History, then what is the percentage of students who passed in both the subjects?

- 55
- 45
- 44
- 50

**Answer:** b

**Solution:**

Let circle M represent students who failed in Science

& Let circle E show students who not passed in History

Unshaped part represents students who passed an exam

Now, % of students failed in Science =n(M) = 30% of students failed in History= n(E) = 45% of students failed in both Science & History = n(M∩ E) = 20

We know that the percentage of students who not passed in either one or both subjects:

n(S ⋃H)= n(S)+ n(H) – n(S ⋂H)

⇒ n(S U H)= 30 + 45- 20

⇒ n(S U H)= 55

∴ % of students who not failed in both subjects = 100 -(% of students who passed in any one subject)

⇒% of students who passed in both of the subjects = 100 – 55 = 45.

## 28) A, B, C starts a race at the same time and the same point in the same direction in a stadium. A completes a circle in 125 seconds, B in 150 second and C in 100 seconds. After what time will they cross again at the same point?

- 25 minutes
- 15 minutes
- 28 minutes
- 20 minutes

**Answer:** a

**Solution:**

The time at which they will meet again at the starting point will be the LCM of 125, 150 and 100 second. Hence,

LCM [125, 150, 95] = 1500 Seconds = 1500/60 minutes = 25 minutes

## 29) Consider numbers between 100 and 1000 such that when each number is divided by 6, 7 and 11, it leaves five as the remainder in each case. What is the sum of the numbers?

- 462
- 929
- 1386
- 1396

**Answer:** c

**Explanation:**

As the number leaves same remained in each case, required numbers = 5 + (common multiples of 6, 7 and 11)

Consider the LCM of 6, 7 and 11.

LCM = 462

⇒ One of the required numbers = 462 + 5 = 467.

## 30) Consider some digits in between 10 and 1000 such that when each number is divided by 6, 7 and 11, it leaves five as the remainder in each case. What are the Original numbers?

- 462
- 234
- 136
- 196

**Answer:** a

**Solution:**

As the number leaves same remained in each case,

∴ required numbers = 5 + (common multiples of 6, 7 and 11)

∴ Consider the LCM of 6, 7 and 11.

LCM = 462

⇒ One of the required numbers = 462.

## Cognizant Verbal Ability Questions

**Analogies:**

### 1) slur : speech : : smudge 😕

**Answer:** Writing.

### 2) Epaulet: shoulder: : ring 😕

**Answer:** Finger.

### 3) Vernacular: place: : fingerprint : ?

**Answer:** Identical.

**Opposites:**

### 4) Corpulent

**Answer:** Slim.

### 5) Adulterate

**Answer:** To corrupt.

### 6) Ambidextrous

**Answer:** Deceitful.

**The following sentence broke into four Parts – A, B, C, D Choose the part which has an error.**

### 7)

- Physician point out that
- there are human processes
- which do not involve
- the use of the sentence.

**Answer:** c. which does not involve (do)

### 8)

- jack order for
- two plates chicken
- and a glass
- of water

**Answer:** b. Two plates chicken

### 9) The succeeding is the batch of questions base on a paragraph or a set of conditions for each issue. Select the best answer choice given.

If it is forbidden by law if the object of an agreement is the doing of an act that is prohibited by law the contract is void.

If it is of nature than, it would defeat the solution of any law is the agreement is empty. If the object of a transaction is such that thing got directly forbidden by law, it will defeat the provision of statuary law.

If the object of an agreement is corrupt, it is void.

An object of an agreement is void if it involves or implies to the personal property of another.

An object of an agreement is void where the constant regards as ignored.

An object of an agreement is void where the constant regards are as opposed to public policy.

### 9.1. An algorithm follows a six-step ZA, ZB, ZC, ZD, ZE, ZF, it gives the following

- ZD should come after ZE
- The 1
^{st}may be ZD, ZA or ZE - ZC and ZB have not to complete before ZD
- ZB must be immediately before ZC

**Answer:** c

### 9.2. If ZA set before ZD must place at

- 2
^{nd} - 4
^{th} - 3
^{rd} - 5
^{th}

**Answer:** b

### 9.3. If ZA followed by ZB then ZA can follow the

- third or fourth
- first or second
- cannot be third
- fourth or fifth
- none

**Answer:** c

### 9.4. If ZE is the third term the number of different operations possible is

- 1
- 2
- 3
- 4
- 5

**Answer:** e

### 10) The following questions base on the given paragraph:

Suraj plants six separate saplings — A, B, C, D, E, F in rows no 1 to 6, according to the following conditions: He must plant A before B and E, He must plant B and D, The third has to be C

### 10.1. Which of the following is acceptable

- AEBDCF
- AFCBED
- CEBADF
- CFAEDB
- DBCEFA

**Answer:** b

### 10.2. Which of the following is true

- C before F
- C before A
- D before E
- B before E
- A before D

**Answer:** c

### 10.3. If he plants F first, then which can plant second

- A
- B
- C
- D
- E

**Answer:** c

### 10.4. Which describes a correct combination of sapling and row?

- B, 6
- A, 3
- D, 2
- E, 6
- C, 1

**Answer:** d

### 10.5. If he plants b 6th which would plant first and second

- A and D
- A and B
- B and A
- D and C
- D and E

**Answer:** a

**Solution:**

If Plant B at 6th position then option “b” and “c” cannot satisfy

Option “d” is not satisfying because plant C should cover position 3, and option

“e” is wrong also because plant E never come before plant A

### 10.6. If he plants D before E and after F he should plant D at

- first
- the second
- fourth
- the fifth
- sixth

**Answer:** d

**Solution:**

because position of plant C is always fix and A always planted before B and E.

### 11) At a particular moment, a watch shows 2 min lag although it is running fast. If it showed a 3 min lag at that moment but also gains by 1/2 min more a day than its current speed, it would show the right time one day sooner than it usually does. How many mins does the watch gain per day?

- 2
- 5
- 6
- 4
- 75

**Answer:** a

**Solution:**

Let fast per day be x, no of days required to show correct time

Condition1 = 2 / x.

Condition2 = 3 / (x + 1/2)

Condition2 is one day sooner hence, 2 / x = 3 / (x + 1/2) + 1 = x^2 +1.5 x – 1 = 0

x = -2 or +1/2. It is running fast so, x = 1/2

Hence the answer is 1/2 min per day.

To verify this for condition 1 it require 4 days (2 % 1/2)

Condition 2 it require 3 days [3 % (1/2 + 1/2)] i.e. 1 day less than condition 1.

### 12) In 400m race A gives B a start of 7 sec and beats him by 24 sec. In another race, A beats B by 10 sec the speeds are in the ratio

- 8:7
- 7:6
- 10:8
- 6:8
- 12:10

**Answer:** c

**Solution:**

A’s Speed: 400/a, a=time taken for A to complete 400m

B’s Speed: 400/ (a+10) = 376/ (a+7)

a=40

A’s Speed = 400/40 = 10

B’s Speed = 400/50 = 8.

### 13) Spotting errors in English:

- The manor is often coming
- to me
- on Sundays
- No Error

**Answer:** a

**Solution: **

Manor often comes to me on Sundays.

### 14) Spotting errors in English:

- Sham just finished
- the poem
- later
- No mistake

**Answer:** a

**Solution:**

Sham had just finished the poem then.

### 15) If VZSCQ can write as ‘XBUFS,’ then what can write as ‘GJSF’?

- ILUH
- FIRE
- REFI
- ERIF

**Answer:** a

**Solution:**

Move two letter backward (-2).

### 16) IF ‘DBSJOH’ can code as ‘FEWHLD’ and TIBSFT is coded as ‘VLFQWP’ how will DBTLFU be coded as in the same code?

- EDXIBP
- FEXIBQ
- EDWPAI
- FEXJCQ

**Answer:** d

**Solution:**

Move +2,+3,+4 forward for first three letters Move -2,-3,-4 backward for the last three letters.

### 17) When Atul saw Ramesh, he recalled, “He is the son of the father of my daughter.” Who is Ramesh?

- Brother-in-law
- Brother
- Cousin
- Uncle

**Answer:** a

**Solution:**

Atul’s daughter’s mother – Atul’s wife;

Atul’s wife’s father – Atul’s father-in-law;

Father-in-law’s son – Atul’s brother-in-law.

So, Ramesh is Atul’s brother-in-law.

### 18) Two Vehicles start from the different places on a road, 200 km apart.1st car runs for 50 km and takes a left turn and then runs 25 km. It then turns right and then runs for another 35 km and then takes the direction back to reach the road. In the meantime, due to a significant break down the other car has run only 40 km along the way. What would be the distance between two vehicles at this point?

- 58 Km
- 85 Km
- 65 Km
- 88 Km

**Answer:** b

### 19) A man walks 11 km toward the south and then turns to the right. After walking 2 km, he turns to the left and walks 7 km. And then he goes back 3 km straight. Now in which direction is he from the starting place?

- South-East
- North-West
- South
- West

**Answer:** b

## Cognizant Technical Interview Questions

## Questions mainly asked from:

- C Theory/Programs
- C++ or Java
- OOPS
- Software Engineering
- Optional – DBMS, Operating Systems, Data Structures

## Cognizant C Programming Interview Questions

### 1) What is a pointer? Define it.

Pointer is a variable which stores the address of other variables which hold some value in it. Directly pointer is used to point values of variables indirectly. We can manipulate its values.

### 2) What is a dangling pointer in C?

Dangling pointer is a pointer which does not point to a valid object of the appropriate type. It appears when a pointer is in the stack but not in the memory in a heap. Char *p =NULL; A dangling pointer attempt to deallocate without allocating space will result in a segmentation fault.

Dangling pointers arise during object destruction, when an object that has an incoming reference is deleted or deallocated, without changing the data of the pointer, so that the pointer points to the memory location of the deallocated memory.

### 3) What is a memory leak in a heap?

When there is a space area in a heap, but no variable is in the stack pointing to that memory.

### 4) What is a data type?

Data Type defines the type of value which are allocated by us to a variable and have a range in between we assign values. E.g., “Int” it is a data type which able to store data between “-32768 to +32768” in C.

### 5) What is the size of the integer data type?

Size of it is 2 Byte or 4 Byte.

### 6) What is malloc?

Allocates requested size of bytes and returned a pointer first byte of allocated space. Malloc is using for dynamic memory allocation.

### Syntax:

### 7) What is a string?

A string is a sequence of characters. It can be defined using the array or by using String header file.

### 8) “/0” in a string?

This symbol shows the ending of the string.

E.g. char a[] = {“s”,”e”,”t”,”/0″};.

### 9) What is recursion?

The process by which a method calls itself directly or indirectly, again and again, is called recursion and the corresponding function.

### 10) What is the difference between a pre-increment operator and post-increment operator?

Pre-increment operator used incrementing the variable value by one before assigning the cost to the variable. Post-increment operator use to incrementing the variable value by one after assigning the value to the variable.

### 11) What are the key features or characteristics OFC language?

- Reliability
- Portability
- Flexibility
- Interactivity
- Modularity
- Efficiency and Effectiveness

### 12) What is embedded C?

Embedded C is the extension of C programming language.

Embedded C is used to develop microcontroller-based applications.

Embedded C includes features not available in standard C like fixed-point arithmetic, named address spaces, and necessary I/O hardware addressing.

Cell phones, MP3 players are some example of embedded systems in which integrated C is used to program and control these devices.

### 13) Which level is C language belonging?

C language is belonging to middle-level language. C language behaves as a bridge between machine level (low level) languages and high-level languages.

C language is more user-friendly than machine level languages. And, C language does not support all the concepts that high-level languages offer. So, C programming language called as middle-level language.

### 14) What is the difference between structured oriented, object-oriented and non-structure oriented programming language?

**Structured oriented programming language –**

In this type of language, large codes fragmented into small programs called functions.

The main focus is on procedures and functions that operate on values

Data moves without any restrictions around the systems from one procedure to another

Program structure follows “Top-Down Approach.”

Example: C, Pascal, ALGOL, and Modula-2

**Object-oriented programming language –**

In this type of language, programs fragmented into objects

The main focus is on the data/values that are manipulating and not on the procedures or functions.

Data is hidden from functions and cannot access by external functions

Program structure follows the “Bottom UP Approach.”

Example: C++, and C# (C sharp)

**Non-structure oriented programming language –**

There is no specific structure rule for programming this language.

Example: BASIC, COBOL, FORTRAN

### 14) What is modifier in C?

Modifiers derive the space to allocate for a variable.

Modifiers are fixed with basic data types to modify (either increase or decrease) the amount of storage allocated to a variable.

For example, storage requirements for int data type are 4 bytes for a 32-bit processor. We can increase range by using long int data type which is 8 byte. We can decrease the range by using short int which is 2 byte.

### 15) What is the difference between variable declaration and variable definition in C?

Variable declaration tells the compiler about data type and size of the variable. Whereas, variable definition allocates memory to the variable

Variable can be declared many times in a program. But, the definition can happen only one time for a variable in a program.

Variable declaration is for assignment of properties and identification to a variable. Whereas, a variable definition is for assignments of storage space to a variable

## Cognizant OOPs Interview Questions

### 1) What are virtual Functions?

In object-oriented programming, in languages such as C++, and Object Pascal, a virtual function or virtual method is an inheritable and overrideable function or method for which dynamic dispatch facilitated. This concept is an essential part of the (runtime) polymorphism portion of object-oriented programming (OOP).

### 2) What is overloading in OOPs?

Overloading is a process used to avoid redundant code where the same method name used multiple times but with a different set of parameters. The actual method that gets called during runtime is resolved at compile time, thus avoiding runtime errors.

### 3) What is overriding?

In any object-oriented programming, Overriding is a process that allows a child class or subclass to provide a specific implementation of functions that is already provided by one of its super-classes or parent classes.

### 4) What is polymorphism?

By using the ability of polymorphism an object can take on multiple types. The frequent use of polymorphism occurs when a parent class refers to an object of the child class. The Java object that can pass more than one IS-A test is polymorphic.

### 5) What is data abstraction?

In oops, abstraction is one of three main principles (along with encapsulation and inheritance). Through the process of abstraction, a programmer hides all but the relevant data about an object to reduce complexity and increase efficiency.

### 6) What is encapsulation?

Encapsulation is one of the primary concepts in object-oriented programming. It describes the idea of combining data in a single class and methods that work on that data, e.g., a class which is a blueprint in java. This concept is also often used to preserve the internal state, of an object from the outside.

### 7) What is Inheritance in java?

In object-oriented programming, inheritance helps new objects to take on the properties of old objects. A class that uses for inheritance is called a base class or superclass. A class that inherits data from a base class is called a subclass or derived class

### 8) What is the constructor?

A constructor is a method which is used to initialize a newly created object and is called just after when memory allocated to the object. It can be used to implement the objects to desired values or default values at the time of object creation.

### 9) What is the destructor?

A destructor used when the initialized object is destructing it called automatically during the destruction of an object. It helps in recovering the heap space and remove files.

## Cognizant Data structure Interview Questions

### 1) What is a Data Structure?

Data Structure is a process in which management or organization of data that enable a more efficient way to organize the data.

### 2) What have linked lists?

A linked list is a set of ordered data and each of its previous nodes connected to its succeeding node. It is like an array but more efficient then array because we can insert or delete data in between the nodes.

### 3) Is the array of data structure?

Yes, because it also handles the data in a structured way.

### 4) Define a binary search Tree?

It is also known as ordered or sorted binary tree. It keeps there nodes or keys in sort form, and the root node of BST is bigger than the left node and smaller than the right node.

### 5) What is a Binary Tree in the data structure?

A binary tree is part of a data structure that has two sub-nodes, a right node, and a left node. In programming, binary trees are an advanced version of the linked list.

### 6) What is the dissimilarity between Push and Pop methods of the stack?

Pushing and popping applies to the way data is stored and fetched from a stack. A push method denotes data being added to it, meaning information is being “pushed” in the stack. On the other hand, a pop method denotes data retrieval/fetch, and in particular, refers to the first data is being fetched.

### 7) What is the dissimilarity between a stack and the array?

A stack base on LIFO pattern. It means that data access follows a sequential process wherein the last data to be entered when the first one deleted. Arrays do not follow a particular order and instead can access by referring to the indexed element within the array.

### 8) What are doubly linked Lists?

Doubly linked lists are a particular part of linked list wherein traversal across the data elements can be done in any directions. This is possible by having two links in every node, one that connects to the next node and another one that links to the previous node.

### 9) What is a queue data structure?

A Queue is a data structure which is linear and follows a fixed order in which the operations occur. The order is always First In First Out (FIFO). An excellent example of a queue is any queue of the customer for a resource where the customer that came first served first. The difference between stacks and queues is while deleting.

### 10) What is a stack data structure?

Basic features of Stack are an ordered list of the similar data type. The stack is LIFO (Last In First Out) data structure, or we can say FILO (First In Last Out) data structure. Push () method is used to insert/enter new elements into the Stack and pop() method is used to remove/delete an element from the stack.

### 11) What is a graph in the data structure?

A graph shows a representation of a set of objects/nodes where some pairs of object/nodes are connected by links/connection. The interconnection of objects are represented by points termed as vertices, and the links that connect the vertices are called edges.

### 12) What is a priority queue?

A priority queue is an abstracted data type which is like a queue or stack data structure, but where additionally each element has a “priority” associated with it. In a priority queue, an element with high priority is served before an element with low priority.

### 13) Show the time complexity of the linked list during insertion?

The time complexity of insertion/deletion in a singly linked list depends upon the position where you want to perform them. For example, if you want to insert an element at the end of the linked list, then you have to traverse/travel the entire list, and hence the complexity will be O(n).

## Cognizant Programming Questions

### 1) Write a program to reverse any number.

This code below is written in Java.

### 2) Write a program to find out some of the digits of the given number.

### 3) Write a program to find out the power of a number.

### 4) Write a program to add two numbers without using the addition operator.

### 5) Write a program to subtract two numbers without using a subtraction operator.

### 6) Write a program to show largest among three numbers using binary minus operator.

### 7) Write a program to show the largest among three numbers using conditional operator.

### 8) Write a program to show the generic root of any number.

### 9) Write a c program to show the prime factor of a given number.

## Cognizant HR Interview Questions

- Tell me about yourself?
- What do you know about this organization?
- Why should we hire you?
- Assume you are hired, then how long would you expect to work for us?
- How would you rate yourself on a scale of 1 to 10?
- What are your achievements in life?
- What is your objective in life?
- What are your strengths?
- What are your weaknesses?
- What are your hobbies?
- Explain, how would you be an asset to this organization?
- What are your salary expectations?

Click here for: HR Interview Questions and Answers