TCS Ninja Previous Year Question Papers  TCS Digital Coding Mock test/ TCS Digital Aptitude Questions  TCS Ninja Coding MCQ Questions  TCS Ninja Coding Questions with answers PDF download
TCS Ninja Previous Year Question Papers  TCS Digital Coding Questions  TCS Ninja Placement papers 2022: Students applying for the TCS Ninja hiring drive for 2019, 2020, 2021, and 2022 blocks may check the TCS Ninja previous questionnaires below. This TCS Ninja test sample question paper is provided for reference purposes only. So students can check the TCS model question papers Ninja specified block recruitment drive. Each year, TCS organizes a recruitment process to recruit the best job hunters with the appropriate skills for their workplace. Below you will find a list of TCS Ninja study material/ TCS Sample question papers for Best Choice. The candidates can also get to know their preparation level and the areas where they lack. This allows the candidates to prepare better and eliminate any mistakes while solving the questions in the exam. To get more Private Jobs click here
 Like this more private jobs interview questions, aptitude questions, previous year question papers, Results, Admit cards, Answer keys, internship details, offcampus details, Exam syllabus, Exam patterns, etc. are instantly you can get in @ Naukrimessenger.com without any free cost
Notification Details  

Recruiter  TCS  
Join our Telegram 
TCS Eligibility Criteria
For more upcoming & latest Graduate Jobs just click here
 Graduate (B.Tech/ BE/ BCA)
TCS Ninja Online Test Pattern  TCS Test pattern (New)
TCS Atlas previous question papers
The selection process consists of three rounds – a written test, a technical and administrative interview, and human resources interview. However, the TCS exam level is moderate and applicants will only qualify for the next round if they clear the written exam. Like this more Exam pattern & syllabus click our website
Section Name  TCS Ninja Questions  Time Duration 

Numerical Ability  26 Questions  40 Minutes 
Verbal Ability  24 Questions  30 Minutes 
Reasoning Ability  30 Questions  50 Minutes 
Programming Logic  10 Questions  15 Minutes 
Handson Coding – 1  01 Questions  15 Minutes 
Handson Coding – 2  01 Questions  30 Minutes 
TCS Ninja Paper Names  TCS Ninja Placement Papers And Written Test Questions  TCS Ninja Coding questions 2022
You can Gain insight into reading the Exam pattern & syllabus. By preparing this you will get to know the difficulties that are faced by candidates while giving the actual examination. It will increase your overall caliber and will be of great help to score well in the exam.
SECTION 1: English
SECTION 2: Quantitative Aptitude
SECTION 3: Programming Concepts
SECTION 4: Coding
 10 Questions 10 Minutes For English Test
 20 Questions 40 Minutes For Quantitative Aptitude
 10 Questions 20 Minutes For Programming Language Efficiency
 1 Questions 20 Minutes For Coding Test
TCS Ninja Question papers PDF  TCS Ninja placement preparation papers List
In the section below you can find the questions mentioned below with answers and solutions. To get more upcoming Question papers click here
 TCS Ninja Aptitude Questions
 TCS Ninja Aptitude Questions – Numerical Ability
 TCS Ninja Aptitude Questions – Reasoning Ability
 TCS Ninja Aptitude Questions – Cognitive Test
 TCS Ninja Questions  TCS Ninja Placement Papers
 TCS Ninja Interview Questions  Technical and HR Questions
 TCS Ninja Coding Questions and Answers (New)
 TCS Ninja Programming Logic Questions
TCS Ninja Questions – TCS Placement Papers – TCS Previous Year Paper
TCS Ninja Questions – HandsonCoding Questions 
Question 01: Given a maximum of four digit to the base 17(10 > A, 11 > B, 12 > C, 16 > G) as input, output its decimal value.
Answer: INPUT 23GF
Solutions
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
int main(){
char hex[17];
long long decimal;
int i = 0, val, len;
decimal = 0;
cin>> hex;
len = strlen(hex);
len–;
for(i = 0;hex[i]!=’\0′;i++)
{
if(hex[i]>=’0’&& hex[i]<=’9′){
val = hex[i] – 48;
}
else if(hex[i]>=’a’&& hex[i]<=’g’){
val = hex[i] – 97 + 10;
}
else if(hex[i]>=’A’&& hex[i]<=’G’){
val = hex[i] – 65 + 10;
}
decimal = decimal + val * pow(17,len);
len–;
}
cout<< decimal;
return 0;
}
Questions 02: One programming language has the following keywords that cannot be used as identifiers: break, case, continue, default, defer, else, for, func, goto, if, map, range, return, struct, type, var.. Write a program to find if the given word is a keyword or not
Input #1:
defer
Output:
defer is a keyword
Input #2:
While
Solutions
#include<iostream>
#include<string.h>
using namespace std;
int main(){
char str[16][10] = {“break”, “case”, “continue”, “default”, “defer”, “else”,”for”,
“func”, “goto”, “if”, “map”, “range”, “return”, “struct”, “type”, “var”};
char input[20];
int flag = 0;
cin >> input;
for(int i = 0; i<16;i++){
if(strcmp(input,str[i]) == 0){
flag = 1;
break;
}
}
if(flag==1){
cout << input << ” is a keyword”;
}
else{
cout << input << ” is not a keyword”;
}
return 0;
}
Question 03: Our hoary culture had several great persons since time immemorial and king Vikramaditya’s Nava Ratna (nine gems) belong to this ilk. They are named in the following shloka:
Among these, Varahamihira was an astrologer of eminence, and his book Brihat Jataka is recommended as the ultimate authority in astrology. He was once talking with Amarasimha, another gem among the Nava ratnas and the author of Sanskrit thesaurus, Amarakosha. Amarasimha wanted to know the final position of a person, who starts from the origin 0 0 and travels per the following scheme.
 He first turns and travels 10 units of distance
 His second turn is upward for 20 units
 The third turn is to the left for 30 units
 The fourth turn is downward for 40 units
 The fifth turn is to the right(again) for 50 units
Constraints:
2<=n<=1000
Input:
3
Solution
import java.util.*;
import java.lang.*;
class Main {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
char c = ‘R’;
int x = 0, y = 0;
while(n>0){
switch(c){
case ‘R’:
x = Math.abs(x) + 10;
y = Math.abs(y);
c =’U’;
break;
case ‘U’:
y = y + 20;
c = ‘L’;
break;
case ‘L’:
x = (x + 10);
c = ‘D’;
break;
case ‘D’:
y = (y);
c = ‘R’;
break;
}
n–;
}
System.out.println(x+” “+y);
}
}
TCS Ninja Aptitude Questions – Verbal Ability questions 
The oral skills of the TCS Ninja Aptitude Questions belong to Part A (Cognitive Skills). Here are 24 questions to ask. These should be resolved within 30 minutes.
Questions 01: The candidates ____ certificates the office could not verify were not permitted to appear before the interview board.
A.Whom
B.Whose
C.Who
D.Which
Answer: Option B
Solutions: The word that precedes the blank is ‘The candidates’ and the word that follows the blank is ‘certificates’. From the context, it can be understood that ‘the certificates belong to the candidates’ or ‘the candidates possess the certificates’.
If we consider the given options, all the options (whom, whose, who, which) are relative pronouns.
So, from the context, it can be understood that the required relative pronoun to be fitted in the blank should reflect the sense of possession.
One such relative pronoun that reflects the sense of possession is ‘whose’ which is given in option B. Hence option B is the correct answer. If we relate the same, the correct sentence is ‘The candidates whose certificates the office could not verify were not permitted to appear before the interview board.’
Use of other options:
 ‘Whom’ is used to represent a person when the person is in the object position of the verb. Example: I submitted the proposal to the person whom I met yesterday.
 ‘Who’ is used to represent a person when the person is in the subject position of the verb. Example: The person who received the proposal has approved the project.
 ‘Which’ is used to represent things and animals. Example: I read the letter which was delivered today.
Q2: Which statement is CORRECT according to the passage?
A.Research about vaccines is not reliable
B.All pandemics are not to be feared
C.Pandemics keep occurring periodically
D.There is no solution for a pandemic
Answer: Option C
Q3: In the fourth paragraph which pandemic is the author referring?
A.An unknown one
B.Small pox
C.COVID19
D.Cholera
Answer: Option A
Q4: What does the writer imply that we should do?
A. Be vigilant about hygiene and health issues.
B.Wear masks when we step out of our homes.
C.Wash our hands and everything we touch carefully.
D.Maintain social distancing and avoid public gatherings.
Answer: Option A
Q5: The part of the sentence below may contain a grammatical error. Identify the part.
A highend machine was inaugurated at the city’s Institute of Medical Sciences which will facilitate 3000 RTPCR tests for Coronavirus in a day.
A.A highend machine was inaugurated
B.at the city’s Institute of Medical Sciences
C.for Coronavirus in a day
D.which will facilitate 3000 RTPCR tests
Answer: Option A
Q6: Select the most appropriate option to complete the sentence.
The final report on the project was __ into three parts.
A.Broken up
B.Broken off
C.Broken away
D.Broken out
Answer: Option A
Q7: Complete the following passage by filling in the blanks (1) and (2) with the right word from the list given below:
Compared with conventional agriculture, organic farming uses fewer pesticides, reduces soil erosion, decreases nitrate leaching into groundwater and surface water, and _________ animal wastes back into the farm. These benefits are ________ by higher food costs for consumers and generally lower yields.
Blank 1: A) recycling B) recycle C) recycles D) recycled
Blank 2: A) increased B) balanced C) counterbalanced D) encountered
A.1D, 2B
B.1D, 2A
C.1C, 2C
D.1B, 2D
Answer: Option C
Q8: Fill in the blanks with the most appropriate pair of words from the options given below:
The Mughal Emperor Akbar, ________ 25th October 1605, shortly ________ his 63rd birthday due to yesterday.
A.dies on/ when
B.died on/ after
C.died at/ after
D.died in/ before
Answer: Option B
Q9: The following three sentences can be revised into one better sentence. Choose the sentence that is the best revision:
I was at the fair. I got lost. I got scared.
A.I am scared after I am lost at the fair.
B.I went to fair and got scared as I was lost.
C.I am lost at the fair so I am too scared.
D.I got lost at the fair and was scared.
Answer: Option D
Q10: What purpose do the calls of the birds serve?
A.They help them locate other birds.
B.They show them the direction during flight.
C.They help the male secure their territory.
D.They assist them in finding food.
Answer: Option C
TCS Ninja Questions – Programming Logic 
Q1:Find Prefix and suffix for the below infix problem statement :
Infix Expression : 11 +20/5*(2015)^6^5
A. Prefix Expression: 11 20 15 20 5 – ^^*6 5/+
Postfix Expression: +20/11*520^^15 6 5
B. Prefix Expression: 11 20 5 20 156 5^^*/+
Postfix Expression: +11/20 *5^^ 20 15 6 5
C. Prefix Expression: 11 20 5 20 15 – ^^^/+6 5
Postfix Expression: +11/^^20*5 20 15 6 5
D. Prefix Expression: +11/20*5^^20 15 6 5
Postfix Expression : 11 20 5 20 15 6 5^^/+
Answer: Option D
Q2: Write the name of a library of functions that is used to perform arithmetic operations on BigInteger and BigDecimal.
Answer: import java.math.*;
Solution: java.math consists of all the required functions related to BigInteger and BigDecimal.
Q3: There are two integer numbers X and Y that are between 0 to 25. The user stores the value under a 5bit number. How many minimum bits are required to store the result of the below expression?
Res=3*(XY)
A.8
B.5
C.7
D.8
Answer: Option D
Solutions: If we perform XY the possible answers shall be from 75 to 75. In order to store this, we need 8 bits.
Q4: Consider the following tree. What will be the preorder traversal?
A. D H E B I F G C A
B. D H E B A F I G C
C. A B D E H C F I G
D. H I D E F G B C A
Answer: Option C
Solutions: In preorder traversal, we have to visit the root first and then left, and finally right.
Q5: Which argument is passed to fflush()?
A.no parameters
B.stdin
C.stdout
D.stderr
Answer: Option B
Solutions: In order to clear the input stream buffer we have to pass stdin to flush.
TCS Ninja Questions – Reasoning Ability 
Q1: In the following diagram, the triangle stands for ‘males’, the circle for ‘doctors’, the rectangle for ‘government employed’, the hexagon for ‘corona warriors’. The numbers in different segments show the number of persons for that segment. How many governmentemployed doctors are either corona warriors or males or both?
A. 22
B. 73
C. 35
D. 38
Answer: Option B
Solutions:
Here we need to find governmentemployed doctors who are either corona warriors or males or both.
To find out the number of governmentemployed doctors who are corona warriors, we need to check the intersection of rectangle, circle, and hexagon and the value is 16.
To find out the number of governmentemployed doctors who are males, we need to check the intersection of rectangle, circle, and triangle and the value is 35.
To find out the number of governmentemployed doctors who are both corona warriors and males, we need to check the intersection of rectangle, circle, hexagon, and triangle and the value is 22.
So, the total number of governmentemployed doctors who are either corona warriors or males or both = 16+35+22 = 73.
Q2: Among 5 objects P, Q, R, S and T
i. R is twice as heavy as T
ii. S is one and half times as heavy as Q
iii. Q and R together weigh as much as S and T together
iv. P and S together are one and half times as heavy as Q and T together
Which among the five is the heaviest of all?
A. Q
B. S
C. P
D. R
Answer: Option B
Solutions
From statement (i), R = 2T — Eq (1)
From statement (ii), S = 1.5Q — Eq (2)
From statement (iii), Q+R = S+T — Eq (3)
From statement (iv), P+S = 1.5(Q+T) — Eq (4)
Substitute Eq (1) and Eq (2) in Eq (3)
Q+2T = 1.5Q+T
0.5Q = T
Q = 2T — Eq (5)
Substitute Eq (5) in Eq (2)
S = 1.5(2T)
S = 3T — Eq (6)
Substitute Eq (5) and Eq (6) in Eq (4)
P+3T = 1.5(2T+T)
P+3T = 4.5T
P = 1.5T
Now, it is obvious that T will be a positive value as T is the weight of a person.
So, among all the above values, S = 3T will be the highest, and hence S will be the heaviest of all.
Q3: There are five rods K, L, M, N, and O. The weight of O is twice L. The weight of L is equal to the weights of K and M together. The weight of M is twice the weight of K. The weight of N is three times the weight of M. If the weight of N is 90 kg, what will be the weight of O?
A. 120 kg
B. 60 kg
C. 105 kg
D. 90 kg
Answer: Option D
Solutions
Given,
The weight of O is twice L
O = 2L — Eq (1)
The weight of L is equal to the weights of K and M together
L = K+M — Eq (2)
The weight of M is twice the weight of K
M = 2K — Eq (3)
The weight of N is three times the weight of M
N = 3M — Eq (4)
Given, N = 90 kg — Eq (5)
From Eq (4), 3M = 90
M = 30 — Eq (6)
Substitute Eq (6) in Eq (3)
30 = 2K
K = 15
Substitute the value of K and M in Eq (2)
L = 15 + 30 = 45
Now, substitute the value of L in Eq (1)
O = 2(45) = 90
Q4: If 30 employees of the Planning department quit Company B and join the Planning department of Company A, then what is the percentage of employees in the Planning Department in the total employees in Company A?
A. 5.34%
B. 6.16%
C. 6.32%
D. 4.48%
Answer: Option C
Solutions
Given, that 30 employees quit Company B and join the Planning department of Company A.
Number of employees in the Planning department of Company A = 46+30 = 76
Total employees in Company A = 1202
Percentage of employees in the Planning Department in the total employees in Company A = (76/1202) X 100 = 6.32%
Q5: Which is the odd term in the following series?
CMQ, FPT, JTX, OYC, UFI
A. FPT
B. OYC
C. JTX
D. UFI
Answer: Option D
Solutions
CMQ: The difference between C and M is 10. The difference between M and Q is 4.
FPT: The difference between F and P is 10. The difference between P and T is 4.
JTX: The difference between J and T is 10. The difference between T and X is 4.
OYC: The difference between O and Y is 10. The difference between Y and C is 4 (Here, the place value of C is 29 because, after Z which is the 26th letter, the 27th letter will be A, the 28th letter will be B and so on)
UFI: The difference between U and F is 11 (Here the place value of F is 32). The difference between F and I is 3.
So, UFI is the odd term of the given series.
TCS Ninja Questions – Numerical Ability Questions 
Q1: Two ants of lengths 1 cm and 1.2 cm crawl in opposite directions with average speeds of 2 and 3 mm per second respectively. How many seconds will they take to cross each other?
A. 4.4
B. 2.8
C. 0.4
D. 1.5
Answer: Option A
Solutions
Relative distance to be covered = Sum of the lengths of ants
= 1 + 1.2
= 2.2 cm
= 22 mm (1 cm = 10 mm)
Relative speed when bodies move in opposite directions = Sum of the speeds
= 2 + 3
= 5 mm per second
Time taken to cross each other = Relative distance / Relative speed
= 22/5
= 4.4 seconds
Q2: The index numbers of five commodities are 121, 123, 125, 126, 128 and the weights assigned to these are respectively 5, 11, 10, 8, 6. Then what is the weighted average index number?
A. 123.8
B. 124.2
C. 124.6
D. 125.2
Answer: Option C
Solutions:
Weighted average = Sum of all the weights / Total number of weights
Sum of all the weights = 121*5 + 123*11 + 125*10 + 126*8 + 128*6
= 605 + 1353 + 1250 + 1008 + 768
= 4984
Number of weights = 5 + 11 + 10 + 8 + 6
= 40
Weighted average = 4984 / 40
= 124.6
Q3: A sum was lent to Ravi for three years by an organization that fixed a yearly rate of 10% compound Interest for repayment along with the condition of recovery in equal installments of Rs.31944. What percentage (correct to two decimal places) above the borrowed amount Ravi had to pay the organization?
A. 18.43
B. 21.25
C. 16.52
D. 20.63
Answer: Option D
Solutions:
Let x be the amount borrowed.
After one year amount will be = 1.1 x
Amount remaining after paying the first installment = 1.1x – 31944
For the next year, this amount acts as the principal
After second year amount will be = 1.1 (1.1x – 31944)
Q4: What is the fourth proportional of 0.006, 1.2 & 6/25?
A. 36
B. 48
C. 4.8
D. 3.6
Answer: Option B
Solutions:
Let the fourth proportional be x
Then,
0.006: 1.2 :: 6/25 : x
0.006 * x = 1.2 * 6/25 (Since Product of means = Product of extremes)
x = (1.2*6)/(25*0.006)
x = 7.2/0.15
x = 48
= 1.21x – 35138.4
Amount remaining after paying the second installment = 1.21x – 35138.4 – 31944
= 1.21x – 67082.4
This acts as principal for the third year
After third year, amount will be = 1.1(1.21x – 67082.4)
= 1.331x – 73790.64
This amount should exactly be equal to the final installment.
Hence, 1.331x – 73790.64 = 31944
1.331x = 105734.64
x = 105734.64/1.331
x = 79440
Borrowed amount = 79440
Amount paid = 31944*3
= 95832
Percentage of extra amount paid = (9583279440)/79440 * 100
= (16392/79440) * 100
= 20.63%
Q5: Which one among the following has the least value?
A. √75 – √74
B. √74 – √73
C. √77 – √76
D. √76 – √75
Answer: Option C
Solutions
Rationalizing the options
√75 – √74 * (√75 + √74)/(√75 + √74) = 1/(√75 + √74)
√74 – √73 * (√74 + √73)/(√74 + √73) = 1/(√74 + √73)
√77 – √76 * (√77 + √76)/(√77 + √76) = 1/(√77 + √76)
√75 – √74 * (√75 + √74)/(√75 + √74) = 1/(√75 + √74)
Comparing all the fractions, 1/(√77 + √76) is the least value as its denominator is the greatest
TCS Ninja Coding Questions  TCS Ninja Coding MCQ Questions
C MCQ  Approx Questions in Test  Importance 

Linked List, Stacks Queues  02  High 
C Basics  01  Med 
Arrays, Functions, Scope  01  Med 
Loops, Data Types  0 – 1  Low 
Coding Marks

Marks


0 Test Case

0 Marks

1 Test Case

5 Marks

2 Test Case

8 Marks

3 Test Case

12 Marks

4 Test Case

18 Marks

5 Test Case

22 Marks

Difference between TCS NQT and TCS Digital Coding Round
TCS NQT  TCS Digital 
2 problem statement  2 problem statement 
2 Qs, 15/30 mins  60 mins 
basic coding questions  advance coding questions(dealing with algorithms and realword problems) 
TCS Ninja Coding Questions with answers PDF – Download Here
TCS Preparation Links 
TCS Atlas previous question papers 
Important Details 
