0% found this document useful (0 votes)
405 views

TCS NQT Programming Logic Questions

Uploaded by

Md Hafeez
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
405 views

TCS NQT Programming Logic Questions

Uploaded by

Md Hafeez
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

7/16/2021 TCS NQT Programming Logic Questions

Link copied Login (https://www.faceprep.in/login/?rurl=/tcs/tcs-nqt-programming-logic-questions/)

to clipboard. Share away! Sign Up


Dismiss
Explore
(https://www.faceprep.in/)
(https://www.faceprep.in/signup/?rurl=/tcs/tcs-nqt-programming-logic-questions/)

TCS NQT Programming Logic


Questions
Published on 20 Apr 2021

In this article, we will be discussing some of the TCS NQT programming logic
questions and answers asked in the previous recruitment tests.

Q1. There are two integer numbers X and Y that are between 0 to 25. The user stores the
value under a 5-bit number. How many minimum bits are required to store the result of the
below expression?

Res=3*(X-Y)

A.8
Explore 'TCS'
B.5
Articles
C.7
(https://www.faceprep.in/tcs#articles)
D.8

Message From Our Learners!


Answer: Option D

Explanation: If we perform X-Y the possible answers shall be from -75 to 75. In order to
store this, we need 8 bits.

Q2:Find Prefix and suffix for the below infix problem statement :

Infix Expression : 11 +20/5*(20-15)^6^5

A. Prefix Expression: 11 20 15 20 5 - ^^*6 5/+


Postfix Expression: +20/11*5-20^^15 6 5

B. Prefix Expression: 11 20 5 20 15-6 5^^*/+


Postfix Expression: +11/20 *5^^ -20 15 6 5

C. Prefix Expression: 11 20 5 20 15 - ^^^/+6 5

https://www.faceprep.in/tcs/tcs-nqt-programming-logic-questions/ 1/9
7/16/2021 TCS NQT Programming Logic Questions
Postfix Expression: +11/^^-20*5 20 15 6Login 5
Link copied to clipboard. (https://www.faceprep.in/login/?rurl=/tcs/tcs-nqt-programming-logic-questions/)

Explore Share away!


(https://www.faceprep.in/)
Sign Up
Dismiss
(https://www.faceprep.in/signup/?rurl=/tcs/tcs-nqt-programming-logic-questions/)

D. Prefix Expression: +11/20*5^^-20 15 6 5

Postfix Expression : 11 20 5 20 15 -6 5^^/+

Answer: Option D

Explanation: Provided the Infix expression the equivalent prefix expression is


+11/20*5^^-20 15 6 5 and equivalent postfix expression is 11 20 5 20 15 -6 5^^/+.

Q3. Write the name of a library of functions that is used to perform arithmetic operations on
BigInteger and BigDecimal.
(https://www.faceprep.in/tcs-nqt-cracker/?
aff_id=418&utm_source=Sidebar_Ads&utm_medium
Answer: import java.math.*;

Explanation: java.math consists of all the required functions related to BigInteger and
BigDecimal.

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

Explanation: In preorder traversal, we have to visit the root first and then left, and finally
right.

(https://www.faceprep.in/tcs-nqt-cracker/?
aff_id=418&utm_source=Article&utm_medium=Article_Ads&utm_campaign=TCS_NQT_Crc&utm_content=TCS_NQT_Crc)

Q5. Which argument is passed to fflush()?

https://www.faceprep.in/tcs/tcs-nqt-programming-logic-questions/ 2/9
7/16/2021 TCS NQT Programming Logic Questions
A.no parameters Login (https://www.faceprep.in/login/?rurl=/tcs/tcs-nqt-programming-logic-questions/)
Sign Up
Link copied to clipboard.
Explore Share away!
(https://www.faceprep.in/) Dismiss
(https://www.faceprep.in/signup/?rurl=/tcs/tcs-nqt-programming-logic-questions/)
B.stdin
C.stdout

D.stderr

Answer: Option B
Explanation: In order to clear the input stream buffer we have to pass stdin to flush.

Q6. What is the name of the method that examines a particular data entity and determines
what data elements need to be associated?

A. Entity-relationship diagram
B. Logic Data modeling

C. Customer Entities
D. Functional Primitive

Answer: Option A
Explanation: An ER diagram shows the relationship among entity sets. An entity set is a
group of similar entities and these entities can have attributes. In terms of DBMS, an entity
is a table or attribute of a table in the database, so by showing the relationship among
tables and their attributes, ER diagram shows the complete logical structure of a database. 

Q7. What will be the output of the below code?

public class Main

static int num=30;

static class Inner 

void msg()

System.out.Println(‘Num: num++);}

public static void main(string args[])

Main.Inner tw=new Main.Inner();

tw.msg()

Answer: Num: 30
Explanation: We are creating the object for the class Inner that is present inside the class
Main. num is initialized to 30 and it is static. When the function msg() invokes it will print
the value as 30 and then it will be updated as 31 since it uses a post-increment operator.

Q8. We cannot overload ______ operator.

A. : :
B. []

C. ()

D. +

Answer: Option A

https://www.faceprep.in/tcs/tcs-nqt-programming-logic-questions/ 3/9
7/16/2021 TCS NQT Programming Logic Questions
Explanation: Scope resolution operator(::) Login helps us in accessing the global variable,
(https://www.faceprep.in/login/?rurl=/tcs/tcs-nqt-programming-logic-questions/)
Sign Up
Link copied to clipboard.
Explore Share away! Dismiss
accessing function outside(https://www.faceprep.in/)
the class, access the namespace and so on. This operator can
(https://www.faceprep.in/signup/?rurl=/tcs/tcs-nqt-programming-logic-questions/)
never be overloaded.

Q9.Which data structure is used to convert an expression from one form to another form?

A. Graph
B. Stack

C. LinkedList
D. Queue

Answer: Option B

Explanation: In order to convert an Infix expression to postfix or vice versa we need to use
a stack for the same.

Q10. Which of the following options best suits for ‘Memory Leak Occurred’

A. Resource allocation pending while debugging the code

B. Program releases resources allocated in the memory


C. Program does not free the memory which is allocated dynamically

D. Occurs due to address assignment failure.

Answer: Option C

Explanation: Whenever we are allocating memory dynamically we have to delete the


memory before the execution of the program completes else a memory leak will happen. If a
program has memory leaks, then its memory usage is satirically increasing since all systems
have a limited amount of memory and memory is costly. Hence it will create problems.

Q11. Select the best suitable answer for the below functions.

sizeof()
strlen

A. sizeof() - Returns size of string including null characters 

strlen() - Returns size of string excluding null characters


B. sizeof() - Returns size of string including null characters 

strlen() - Returns size of string including null characters


C. sizeof() - Returns size of string excluding null characters 

strlen() - Returns size of string excluding null, characters


D. sizeof() - Returns size of string excluding null characters 

strlen() - Returns size of string including null characters

Answer: Option A

Explanation: sizeof() always gives the total size of any datatype allocated by the compiler.
Where the strlen() gives the length of the string i.e number of characters in a string.

Q12. In a Singly Circular Linked List, how many address fields are there?

https://www.faceprep.in/tcs/tcs-nqt-programming-logic-questions/ 4/9
7/16/2021 TCS NQT Programming Logic Questions

Link copied Login (https://www.faceprep.in/login/?rurl=/tcs/tcs-nqt-programming-logic-questions/)

to clipboard. Share away! Sign Up


Dismiss
Explore
(https://www.faceprep.in/)
A. 1+1 (https://www.faceprep.in/signup/?rurl=/tcs/tcs-nqt-programming-logic-questions/)

B. 2+1
C. 1

D. 2

Answer: Option C

Explanation: Always a singly linked list will have a data field and an address field. The last
node of the linked list will be pointing the head if it is a circular linked list else it will be
pointing to null.

Q13. The primary mission of an analyst or systems designer is to:

A. calculate the Return on Investment

B. development of Software Evaluation Tool


C. create a Data Flow Diagram

D. extract the physical requirements of the users and convert them to software

Answer: Option D

Explanation: System designers are intended to create software based on the requirements
of their clients. They need to  extract the physical requirements of the users and convert
them to software.

Q14. _______ is a process to identify the key aspects of an entity and hiding the rest.

A. Encapsulation
B. Inheritance

C. Abstraction
D. Polymorphism

Answer: Option C

Explanation: Abstraction is hiding the implementation and showing the functionality alone.
Whereas Encapsulation binds the variables data and code acting o data to one single unit.

Q15. Which one is not a type of topology?

A. Star-topology

B. Circuit-topology
C. Ring-topology

D. Bus-topology

Answer: Option B

Explanation: A Network Topology is the arrangement with which computer systems or


network devices are connected to each other. We have Star-topology, Ring-topology, Bus-
topology, Mesh-topology, Tree-topology, etc.

https://www.faceprep.in/tcs/tcs-nqt-programming-logic-questions/ 5/9
7/16/2021 TCS NQT Programming Logic Questions

Link copied Login (https://www.faceprep.in/login/?rurl=/tcs/tcs-nqt-programming-logic-questions/)

to clipboard. Share away! Sign Up


Dismiss
Explore
(https://www.faceprep.in/)
(https://www.faceprep.in/signup/?rurl=/tcs/tcs-nqt-programming-logic-questions/)

(https://bit.ly/32vSVOf)

Q16. The statement printf (“%d, 25 ? 5 ? 0 : 5 : 25); will print

A. 5
B. Compile-time error

C. 0

D. 25

Answer: Option C

Explanation: The statement that was used is nothing but a ternary or conditional operator.

Q17. Integer m=10, n= 35, p=5, d=6

Comment about the output of the given two statements


Print m*n + p/d

Print p/d + m*n

A. Differ by 10
B. Same

C. Differ by 20
D. Differ due to left and right precedence

Answer: Option B

Explanation:
m*n + p/d = 10*35 + 5/6 = 350 + 0 = 350

p/d + m*n = 5/6 + 10*35 = 0 + 350 = 350


Both gives the same answer

Q18. When we implement stack by using linked list then:

A. Insertion of the node is done from the end and deletion from the end
B. Insertion of the node is done from beginning and deletion from end

C. Insertion of the node is done from beginning and deletion from beginning
D. Insertion of the node is done from end and deletion from beginning

Answer: Option C

https://www.faceprep.in/tcs/tcs-nqt-programming-logic-questions/ 6/9
7/16/2021 TCS NQT Programming Logic Questions

Link copied Login (https://www.faceprep.in/login/?rurl=/tcs/tcs-nqt-programming-logic-questions/)

to clipboard. Share away! Sign Up


Dismiss
Explore
(https://www.faceprep.in/)
(https://www.faceprep.in/signup/?rurl=/tcs/tcs-nqt-programming-logic-questions/)
Explanation: Whenever you are implementing a stack using Linked list both insertion and
deletion should happen at the same end. Here both A and C are correct. But in stack always
we will deal the data in the top i.e beginning hence option c is the best answer.

Q19. Match the followings:

Index 1
Math functions in C language
Index 2
Output in float data type

A ceil(3.6) 1 32.000000

B floor(3.6) 2 3.000000

C pow(2,5) 3 12.000000

D abs(-12) 4 25.000000

5 4.000000

6 0.000000

A. A-5, B-2, C-4, D-3

B. A-2, B-5, C-4, D-3


C. A-5, B-2, C-1, D-6
D. A-2, B-6, C-1, D-3

Answer: None of the mentioned options is correct. The correct answer is


A - 5, B - 2, C - 1, D - 3

Q20. The kind of software testing you can do when you have both the source code and the
executable code in hand, is called as?

A. Red Box Testing

B. Black Box Testing


C. White Box Testing
D. Blue Box Testing

Answer: Option C

Explanation: White Box Testing is a software testing technique in which internal structure,
design, and coding of software are tested to verify the flow of input-output and to improve
design, usability, and security. In white-box testing, code is visible to testers so it is also
called Clear box testing, Open box testing, Transparent box testing, Code-based testing,
and Glass box testing.

Do watch the video below for more TCS NQT Programming Logic Questions.

https://www.faceprep.in/tcs/tcs-nqt-programming-logic-questions/ 7/9
7/16/2021 TCS NQT Programming Logic Questions

Link copied Login (https://www.faceprep.in/login/?rurl=/tcs/tcs-nqt-programming-logic-questions/)

to clipboard. Share away! Sign Up


Dismiss
Explore
(https://www.faceprep.in/)
(https://www.faceprep.in/signup/?rurl=/tcs/tcs-nqt-programming-logic-questions/)

Suggested Articles:

TCS NQT Questions | Reasoning Ability (https://www.faceprep.in/tcs/tcs-nqt-questions-


reasoning-ability/)
TCS NQT Questions | TCS NQT Placement Papers with solutions
(https://www.faceprep.in/tcs/tcs-ninja-placement-papers/)

TCS NQT Questions | Verbal Ability Questions (https://www.faceprep.in/tcs/tcs-ninja-


english-questions/)
TCS NQT Interview Questions for TCS National Qualifier Test | Technical and HR Questions
(https://www.faceprep.in/tcs/tcs-ninja-interview-questions/)

TCS Coding Questions and Answers (Latest) (https://www.faceprep.in/tcs/tcs-coding-


questions/)
TCS NQT Numerical Ability Questions and Answers (https://www.faceprep.in/tcs/tcs-nqt-
questions-numerical-ability/)

Tcs (Https://Www.Faceprep.In/Tcs)

   

If you have any feedback about this


article and want to improve this, please write to
[email protected]

(https://www.faceprep.in/)

COMPANIES PROGRAD FACE PREP SOCIAL


TCS (https://www.faceprep.in/tcs/) Cognizant
About ProGrad Our Story Youtube
(https://www.faceprep.in/cognizant)
(https://www.faceprep.in/prograd/)(https://www.focusacademy.in/ourstory/)(https://www.youtube.com/channe
AMCAT IBM (https://www.faceprep.in/ibm/)
ProGrad Microdegree Contact Us Facebook (https://www.facebook.c
oDJMA)
(https://www.faceprep.in/amcat- (https://prograd.org/microdegree/) (https://www.faceprep.in/contact/)
WIPRO BYJU's ProGrad Bootcamp Terms & Conditions WhatsApp (https://www.focusaca
exam/)
(https://www.faceprep.in/wipro/) (https://www.faceprep.in/byjus/)
(https://prograd.org/bootcamp/) (https://www.faceprep.in/terms-and-
Infosys Deloitte Privacy Policy Instagram (https://www.instagram
conditions/)
(https://www.faceprep.in/infosys/) (https://www.faceprep.in/deloitte/) (https://www.faceprep.in/privacy-policy/)
TATA ELXSI eLitmus Telegram (https://t.me/faceprepoff
(https://www.faceprep.in/tata-elxsi/) (https://www.faceprep.in/elitmus- PLACEMENT PREP
Capgemini TCS Ninja Linkedin (https://www.linkedin.com
exam/)
(https://www.faceprep.in/capgemini/)(https://www.faceprep.in/tcs/)

https://www.faceprep.in/tcs/tcs-nqt-programming-logic-questions/ 8/9
7/16/2021 TCS NQT Programming Logic Questions
Accenture Cocubes Articles
Login (https://www.faceprep.in/login/?rurl=/tcs/tcs-nqt-programming-logic-questions/)
Sign Up
Link copied to clipboard.
Explore Share away!
(https://www.faceprep.in/) Dismiss
(https://www.faceprep.in/accenture/) (https://www.faceprep.in/cocubes- (https://www.faceprep.in/articles/)
(https://www.faceprep.in/signup/?rurl=/tcs/tcs-nqt-programming-logic-questions/)
Tech Mahindra Mindtree Tests (https://www.faceprep.in/tests/)
exam/)
(https://www.faceprep.in/tech- (https://www.faceprep.in/mindtree/)
Videos
mahindra/)
SUBJECTS (https://www.faceprep.in/videos/)
Webinars
Quantitative Aptitude Python (https://www.faceprep.in/webinars/)
(https://www.faceprep.in/quantitative-(https://www.faceprep.in/python/)
Java (https://www.faceprep.in/java/) C (https://www.faceprep.in/c/)
aptitude/)
Data Structures Algorithms
(https://www.faceprep.in/data- (https://www.faceprep.in/algorithms/)
Verbal Ability Logical Reasoning
structures/)
(https://www.faceprep.in/verbal- (https://www.faceprep.in/logical-
ability/) reasoning/)

© Focus 4D Career Education Pvt. Ltd. All rights reserved

https://www.faceprep.in/tcs/tcs-nqt-programming-logic-questions/ 9/9

You might also like