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 Programming questions asked in the TCS NQT exam.
Programming Test For | TCS NQT |
---|---|
Number of Questions | 10 Questions |
Time Limit | 15 Mins |
Difficulty | High |
- There will be no negative marking.
- TCS NQT is adaptive this year.
- 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 a cut-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 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
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
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
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));
5. Which of the below function is NOT declared in math.h ?
a. acos()
b. exp()
c. pow()
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[]
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
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
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
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
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
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
13. Which of the following uses structure?
a. Linked Lists
b. Binary Tree
c. Array of structures
d. All of these
14. Strings are character arrays. The last index of it contains the null-terminated character
a. \t
b. \n
c. \1
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
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
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
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
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–];
}
return low;
}
a. 6
b. 9
c. 5
d. 11
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
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()
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
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
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
TCS NQT Programming MCQ questions
25. Where the local variable are stored?
a. OS
b. Stack
c. Disk
d. None of these
26. What is recursion?
a. A function calls repeatedly
b. A function calls another function repeatedly
c. Looping
d. A function calls itself repeatedly
27. Which of this is used to skip one iteration:
a. continue
b. break
c. goto
d. return
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
29. Which of the below function is NOT declared in string.h?
a. strcpy()
b. strlen()
c. strptr()
d. strupr()
30. What is the output of the below mentioned program?
#include<stdio.h>
#define square(P) P x P
void main()
{
Int i;
i = 64/ square(4);
Printf(“%d”, i);
Return 0;
}
a. 16
b. 54
c. 4
d. Compiler error
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