500+ Latest TCS NQT Programming Questions and Answers 2021 - 2022 - MegaNaukri (2023)

Find the Latest TCS NQT Programming Questions and Answers.There are a total of 10 questions asked and the time is 15 mins given for you to solve. In TCS NQT Programming Logic the difficulty level is very much high as compared to other sections of the TCS NQT test. Kindly check all the questions for better preparation.

Here, you will find all the similar types of previous year questions based on the TCS NQT Syllabus and all the basic details for the Programmingquestionsasked in theTCS NQT exam.

Programming Test ForTCS NQT
Number of Questions10 Questions
Time Limit15 Mins
DifficultyHigh

IMPORTANT NOTE:

  1. There will be no negative marking.
  2. TCS NQT is adaptive this year.
  3. You will not get any extra rough paper in the exam as a calculator and Rough Paper will be available on your Desktop Screen. You are not allowed to move your eyes down while giving the examination.

TCS NQT Programming Logic section has acut-off of 6 to 7 questions.Moreover, this section has NO negative marking.

TCS NQT Programming Syllabus

The following topics are asked –

  • Data Types in TCS MCQ c questions
  • Functions and Scope
  • Recursion and Iteration
  • Questions on File Handling
  • Questions on Array
  • Questions on Variables and Registers
  • TCS Questions on Loops
  • TCS Questions on Command Line Arguments

Most Asked TCS Questions in C MCQ Sections

  • TCS Questions Misc

TCS Computer Science Papers – C Language Part 2

  • TCS Questions on OOPS
  • Input-Output Questions
  • Stacks and Queue
  • Linked List
  • Trees
  • Graphs
  • Dynamic Programming and Greedy
  • Hashing
  • Searching and Sorting
  • Time Complexity

TCS NQT Programming Questions and Answers

1. Is there any difference between the following declarations?
1 : extern int fun();
2 : int fun();

a. Both are identical
b. No difference, except extern int fun(); is probably in another file
c. int fun(); is overrided with extern int fun();
d. None of these

Show answer

b. No difference, except extern int fun(); is probably in another file

Explanation

extern int fun(); declaration in C is to indicate the existence of a global function and it is defined externally to the current module or in another file.
int fun(); declaration in C is to indicate the existence of a function inside the current module or in the same file.

2. Which of the fplowing statements should be used to obtain a remainder after dividing 3.14 by 2.1?

a. rem = 3.14 % 2.1;
b. rem = modf(3.14, 2.1);
c. rem = fmod(3.14, 2.1);
d. Remainder cannot be obtain in floating point division

Show answer

c. rem = fmod(3.14, 2.1);

Explanation

fmod(x,y) – Calculates x modulo y, the remainder of x/y. This function is the same as the modulus operator. But fmod() performs floating point divisions.

3. In C, if you pass an array as an argument to a function, what actually gets passed?

a. Value of elements in array
b. Base address of the array
c. Address of the last element of array
d. First element of the array

Show answer

b. Base address of the array

Explanation

The statement ‘b’ is correct. When we pass an array as a function argument, the base address of the array will be passed.

4. Select the missing statement?
#include<stdio.h>
long int fact(int n);
int main()
{
\\missing statement
}
long int fact(int n)
{
if(n>=1)
return n*fact(n-1);
else
return 1;
}

a. printf(“%ld\n”,fact(5));
b. printf(“%d\n”,fact(5));
c. printf(“%u\n”,fact(5));
d. printf(“%ll\n”,fact(5));

Show answer

a. printf(“%ld\n”,fact(5));

(Video) TCS Coding Questions | Data Analyst Interview Questions and Answers

5. Which of the below function is NOT declared in math.h ?

a. acos()
b. exp()
c. pow()
d. and()

Show answer

d. and()

6. While declaring parameters for main, the second parameter argv should be declared as

a. char * argv[]b. char argv
c. char ** argv[]d. char argv[]

Show answer

a. char * argv[]

7. Predict the output of the following code:

main()
{
int var=20; // scope of the local variable is within function or block printf(“%d,”,var); //outer block
{
int var=30; //Inner block
printf(“%d”,var);
}
}

a. Error
b. 20,20
c. 20,30
d. Garbage value

Show answer

c. 20,30

8. Predict the output of following code:

main()
{
int var=20; // scope of the local variable is within function or block printf(“%d,”,var); //outer block
{
int var=30; //Inner block
printf(“%d,”,var);
}
printf(“%d”,var); //again in outer block
}

a. Error
b. 20,20,20
c. 20,30,20
d. Garbage value

Show answer

c. 20,30,20

9. If a function’s return type is not explicitly defined then it’s default to ______ (In C).

a. void
b. float
c. Error
d. int

Show answer

d. int

10. How many times loop will executed?
#include<stdio.h>
int main()
{
int x,y;
for(x=5;x>=1;x–)
{
for(y=1;y<=x;y++)
printf(“%d\n”,y);
}
}

a. 11
b. 14
c. 15
d. 10

Show answer

c. 15

TCS NQT Programming logic questions

11. Which of the following indicate the end of file ?

a. feof()
b. EOF
c. Both feof() and EOF
d. None of the mentioned

Show answer

c. Both feof() and EOF

12. How many times hello will print ?
#include<stdio.h>
int main(void)
{
int i;
for(i=0;i<5;i++);
printf(“hello”);
}

a. 5
b. Runtime error
c. Compilation error
d. 1

Show answer

d. 1

13. Which of the following uses structure?

a. Linked Lists
b. Binary Tree
c. Array of structures
d. All of these

Show answer

d. All of these

14. Strings are character arrays. The last index of it contains the null-terminated character

(Video) TCS NQT Latest Paper Solved (with Tricks) | जो पढ़ाया वही आया | Numerical Ability 19 August Part 2

a. \t
b. \n
c. \1
d. \0

Show answer

d. \0

15. How many times loop will executed ?
#include<stdio.h>
int main()
{
int i;
for(i=0;i<5;i++)
{
printf(“Hello\n”);
}
}

a. 2
b. 3
c. 1
d. 5

Show answer

d. 5

16. What is the similarity between enum and struct ?

a. nothing in common
b. can assign new values
c. can create new data types
d. they are same

Show answer

c. can create new data types

17. The pre-order traversal sequence of a binary search tree is 40, 30, 20, 25, 35, 33, 49, 45, 52. What is a possible post-order traversal sequence of the same tree?

a. 25, 20, 33, 35, 30, 45, 52, 49, 40
b. 45, 52, 49, 40, 25, 20, 33, 35, 30
c. 33, 35, 30, 45, 52, 49, 40, 25, 20
d. 30, 45, 52, 49, 40,25, 20, 33, 35

Show answer

a. 25, 20, 33, 35, 30, 45, 52, 49, 40

18. Consider the following recursive function that takes two arguments.

unsigned int rec(unisgned int k, unsigned int m) {

if (k>0) return (k>m + rec{k/m, m}};

else return 0;

}

What is the value returned by rec9789, 10)?

a. 19
b. 40
c. 24
d. 36

Show answer

c. 24

19. What is the Output of this program?

#include<stdio.h>

int main()

{

int N=10;

int sortedInputs[]={2,4, 7, 13, 17, 18, 21, 24, 26, 31};

printf(“%d”, foo(sortedInputs, N});

return 0,

}

int foo(int sortedInputs[], int N)

{

int low=0, high=N-1, lowSum=0, highSum=0;

while(high-low>0)

{

if(lowSum<highSum)

lowSum+= sortedInputs[low++];

else

highSum+=sortedInputs[high–];

}

(Video) Everything You Need To Know About TCS Paid NQT Exam: Difference between Free NQT and Paid NQT exam?

return low;

}

a. 6
b. 9
c. 5
d. 11

Show answer

a. 6

20. Guess the output:
main()
{
printf(“%d”,​sizeof(‘a’));
//same as → sizeof(97)
}

a. 1 or 3
b. 2 or 4—
c. Garbage value
d. ASCII value of a

Show answer

b. 2 or 4—

Explanation

sizeof takes ascii value of character and determines number of bytes required by it. Ascii is number, Number is of type int. so integer requires either 2 in 16or 4 in 32 bit machine

Programming logic questions for TCS NQT

21. Which of the following does not require to include math.h header file?

a. rand()
b. sqrt()
c. pow()
d. sinh()

Show answer

a. rand()

22. What is a step-by-step procedure used to solve a problem called?

a. application program
b. algorithm
c. operating system
d. all of these

Show answer

b. algorithm

23. A memory leak happens when?

a. when realloc() is called on a pointer that is not allocated
b. a program allocated memory in Stack
c. a program allocated memory in heap but forget to delete it
d. when an using pointer is freed using free function

Show answer

c. a program allocated memory in heap but forget to delete it

Explanation

memory leak happens when program allocated memory in heap but forget to delete it

24. What is the purpose of ftell?

a. To get the current file name
b. To get the current file position
c. To get the current file attributes
d. To get the current file status

Show answer

b. To get the current file position

Explanation

Ftell() is used to find out the current position of file pointer in the file with respect to starting of the file

TCS NQT Programming MCQ questions

25. Where the local variable are stored?

a. OS
b. Stack
c. Disk
d. None of these

Show answer

b. Stack

Explanation

The local variable are stored in Stack

(Video) Big News|| TCS Mega Hiring for 2022 Passouts || Free Mega TCS NQT Dates Announced #tcsnqt #nqt #tcs

26. What is recursion?

a. A function calls repeatedly
b. A function calls another function repeatedly
c. Looping
d. A function calls itself repeatedly

Show answer

d. A function calls itself repeatedly

Explanation

In recursion, function calls itself repeatedly

27. Which of this is used to skip one iteration:

a. continue
b. break
c. goto
d. return

Show answer

a. continue

28. What is the output of the following pseudo code ?
Int a = 456, b, c, d = 10;
b = a / d;
c = a – b;
print c

a. 410.4
b. 411
c. 411.4
d. None of these

Show answer

b. 411

29. Which of the below function is NOT declared in string.h?

a. strcpy()
b. strlen()
c. strptr()
d. strupr()

Show answer

c. strptr()

Explanation

strptr() is NOT declared

30. What is the output of the below mentioned program?

#include<stdio.h>

#define square(P) PxP

void main()

{

Int i;

i = 64/ square(4);

Printf(“%d”, i);

Return 0;

}

a. 16
b. 54
c. 4
d. Compiler error

Show answer

c. 4

For More Questions Get TCS NQT Premium Preparation Material

Expect 60%-70% similar question in TCS NQT Exam

This Product Includes all the questions asked in TCS NQT

  • Coding Question
  • Numerical Ability
  • Programming logic
  • Verbal Ability
  • Reasoning ability
  • Sample Papers
  • Quantitative Aptitude

Complimentary Bonus

  • 600+ Technical Programming and Coding Questions
  • TCS HR interview handwritten notes

See Buyers what say about our Product

Buy Now at Special Discount TCS NQT Premium Preparation Material

(Video) PYTHON MOCK INTERVIEW 2 | PYTHON INTERVIEW 2| PYTHON INTERVIEW FOR BEGINNERS , #pythoninterview

Videos

1. PYTHON MOCK INTERVIEW | PYTHON INTERVIEW 1| PYTHON INTERVIEW FOR BEGINNERS , #pythoninterview
(Shiva Concept Solution)
2. Free Live DSA Class 17/02/2022 - 21/02/2022 | DSA Class by Upasana Ma'am | Live DSA Doubt Session
(OnlineStudy4u)
3. TCS NQT 2022 Registration Process In Tamil | TCS NQT Preparation 2022 | NQT 2022 Exam Pattern
(Career Growth 360)
4. NOKIA interview experience 2022 | How to get a job in nokia | nokia written test | nokia interview
(Tech My Hire)
5. Common HR interview questions & answers for freshers | Frequently asked interview questions
(Tech My Hire)
Top Articles
Latest Posts
Article information

Author: Maia Crooks Jr

Last Updated: 12/22/2022

Views: 5990

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Maia Crooks Jr

Birthday: 1997-09-21

Address: 93119 Joseph Street, Peggyfurt, NC 11582

Phone: +2983088926881

Job: Principal Design Liaison

Hobby: Web surfing, Skiing, role-playing games, Sketching, Polo, Sewing, Genealogy

Introduction: My name is Maia Crooks Jr, I am a homely, joyous, shiny, successful, hilarious, thoughtful, joyous person who loves writing and wants to share my knowledge and understanding with you.