TCS NQT Programming Questions | TCS Coding Questions 2021 | TCS Coding Questions 2020
In this article TCS NQT Programming Questions you will get all the sample and frequently asked questions, which will help you in attending TCS NQT exam.
A. Changed within function.
B. Assigned an integer value.
C. None of these
D. Passed to a function as argument.
A. Linked Lists
B. Array of structures
C. All of these
D. Binary Tree
A. \t
B. \1
C. \0
D. \n
A. String
B. Structure
C. Array
D. Files
A. free();
B. malloc(variable_name, 0)
C. dealloc();
D. memalloc(variable_name, 0)
A. conio.h
B. stdio.h
C. math.h
D. Dos.h
A. Pointer to integer
B. None of these
C. Pointer to pointer
D. Invalid declaration
A. (underscore)
B. – (hyphen)
C. | (pipeline)
D. * (asterisk)
A. Uppercase letters
B. None of these
C. Lowercase letters
D. Camel Case letters
A. They both are the same
B. Run time errors are automatically displayed in stderr
C. Both are connected to the screen by default.
D. stdout is line buffered but stderr is unbuffered.
1. main() function should always be the first function present in a C program file
2) all the elements of an union share their memory location
3) A void pointer can hold address of any type and can be typcasted to any type
4) A static variable hold random junk value if it is not initialised
Which of the above are correct statements?
A) 2,3
B) 1,2
C) 1,2,3
D) 1,2,3,4
Explanations
In a file you can write a function before main() – False
all the elements of an union share their memory location – True.
A void pointer can hold address of any type and can be typcasted to any type – True
Static value – False as value is 0
In C, if an object that has static storage duration is not initialized explicitly, then:
— if it has pointer type, it is initialized to a NULL pointer;
— if it has arithmetic type, it is initialized to (positive or unsigned) zero;
— if it is an aggregate, every member is initialized (recursively) according to these rules; — if it is a union, the first named member is initialized (recursively) according to these rules.
A) The value returned by the function does not change
B) all the variable declared inside the function automatically will be assigned initial value of zero
C) It should be called only within the same source code / program file.
D) None of the other choices as it is wrong to add static prefix to a function
Access to static functions is restricted to the file where they are declared. Therefore, when we want to restrict access to functions, we make them static
while (0 == 0) { }
A) It has syntax error as there are no statements within braces {}
B) It will run forever
C) It compares 0 with 0 and since they are equal it will exit the loop immediately
D) It has syntax error as the same number is being compared with itself
while( 0==0) {} is equivalent to while(1) {}
A. The element will be set to 0.
B. The compiler would report an error.
C. The program may crash if some important data gets overwritten.
D. The array size would appropriately grow.
Explanation:
If the index of the array size is exceeded, the program will crash. Hence “option c” is the correct answer. But the modern compilers will take care of this kind of errors.
int (*ptr)[10];
A. ptr is array of pointers to 10 integers
B. ptr is a pointer to an array of 10 integers
C. ptr is an array of 10 integers
D .ptr is an pointer to array
A. Value of elements in array
B. First element of the array
C. Base address of the array
D. Address of the last element of array
Explanation:
The statement ‘C’ is correct. When we pass an array as a function argument, the base address of the array will be passed.
int fun(int arr[]);
int fun(int arr[2]);
A. Yes
B. No
Explanation:
No, both the statements are same. It is the prototype for the function fun() that accepts one integer array as an parameter and returns an integer value.
A. Yes
B. No
Explanation:
Both mean two different things. arr gives the address of the first int, whereas the &arr gives the address of array of ints.
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
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.
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
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.
main()
{
int a= – – 2;
printf(“%d”,a);
}
A. 2
B.-2
C. 1
D. Error
–2 is incorrect, // Invalid because lvalue is required to increment
main()
{
int i=-1;
-i; //No change in value of i
printf(“%d,%d”,i,-i);
}
A. -1, 1
B. -1, -1
C. 1, 1
D. 0, 1
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,30
C. 20,20
D. Garbage value
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,30,20
C. 20,20,20
D. Garbage value
main()
{
int i=10;
printf(“%d,%d”,++i,++i);
}
A. 11,12
B. 12,11
C. 10,11
D. 11,10
TCS NQT 2020 Coding Questions With Answers | TCS NQT Programming Logic Questions: Click here
For TCS NQT 2021 Interview Questions, English and Programming Set 1: Click here
For TCS NQT 2021 Interview Questions, English and Programming Set 2: Click here
TCS NQT 2021 Aptitude Questions Set: Click here
Technical Interview Questions of TCS: Click here
HR Interview Questions of TCS: Click here
How To Write Resume For Getting Shortlisted In TCS: Click here
If You Want To Get More Daily Such Jobs Updates, Career Advice Then Join the Telegram Group From Given Link And Never Miss Update.
Join Telegram Group of Daily Jobs Updates for 2010-2021 Batch: Click Here
TCS NQT 2020 Programming Logic Coding Questions With Answer: Click here
Why You’re Not Getting Response From Recruiter?: Click here
Top 5 High Salary Jobs in India IT Sector 2020: Click here
How To Get a Job Easily: Professional Advice For Job Seekers: Click here
Cognizant Latest News: Up To 20K+ Employees Will Be Hired: Click here
Jio vs Airtel vs Vodafone- Idea 2 Gb Per Day Data Plan Comparison: Click here
Lenovo Legion Three Gaming Laptops Launched In India: Click here
COVID-19 Live Tracker India & Coronavirus Live Update: Click here
Career Tips for Freshers: Top 7 Hacks To Land Your Target Job: Click here
Feel Like Demotivated? Check Out our Motivation For You: Click here
List of Best Sites To Watch Free Movies Online in 2020: Click here
5 Proven Tips For How To Look Beautiful and Attractive: Click here
Home Workouts During The Lockdown For Fitness Freaks: Click here
Google Certification 100,000 Courses For Online Certificates: Click here