TCS NQT Questions and Answers | TCS NQT Questions 2021 | TCS NQT Coding Questions PDF

0
14661
TCS Walk-in Drive 2023
TCS Walk-in Drive 2023

TCS NQT Questions and Answers | TCS NQT Questions 2021 | TCS NQT Coding Questions PDF

In this article TCS NQT Questions and Answers you will get all the sample and frequently asked questions, which will help you in attending TCS NQT exam.

1. Property which allows to produce different executable for different platforms in C is called?


A. File inclusion
B. Selective inclusion
C. Conditional compilation
D. Recursive macros

Explanation:
Conditional compilation is the preprocessor facility to produce different executable.

2. C preprocessors can have compiler specific features.


A. true
B. false
C. Depends on the standard
D. Depends on the platform

Explanation:
pragma is compiler specific feature.

3. Preprocessor feature that supply line numbers and file names to compiler is called?


A. Selective inclusion
B. macro substitution
C. Concatenation
D. Line control

4. Which of the following are C preprocessors?

A. #ifdef
B. #define
C. #endif
D. All of the mentioned.

5. The C-preprocessors are specified with _________symbol.


A. #
B. $
C. ” ”
D. None of the mentioned

6. What is the output of this C code?

define a 20
int main()
{
const int a = 50;
printf(“a = %d\n”, a);
}


A. a = 50
B. a = 20
C. Run time error
D. Compilation Error

Explanation:
The #define substitutes a with 20 leaving no identifier and hence compilation error.
Complilation Error: expected identifier or ‘(’ before numeric constant

7. What is the output of this C code?

int main()
{
int var = 010;
printf(“%d”, var);
}


A. 2
B. 8
C. 9
D. 10

Explanation:
010 is octal representation of 8.

8. enum types are processed by?


A. Compiler
B. Preprocessor
C. Linker
D. Assembler

9. What is the output of this C code?

int main()
{
const int a;
a = 32;
printf(“a is %d”, a);
return 0;
}


A. a is 32
B. Compile time error
C. Run time error
D. none

Explanation:
Since the constant variable has to be declared and defined at the same time, not doing it results in an error.

10. Comment on the output of this C code?

int const print()
{
printf(“Cybertecz.in”);
return 0;
}
void main()
{
print();
}


A. Cybertecz.in is printed infinite number of times
B. Cybertecz.in
C. Runtime Error
D. complilation error

11. Does this compile without error?

int main()
{
int k;
{
int k;
for (k = 0; k < 10; k++);
}
}


A. Yes
B. No
C. Depends on the compiler
D. Depends on the C standard implemented by compilers

12. What is the output of this C code?

void main()
{
int k = 4;
float k = 4;
printf(“%d”, k)
}

A. Compile time error
B. 4
C. 4.0000000
D. 4.4

Explanation:
Since the variable k is defined both as integer and as float, it results in an error.

13. A variable declared in a function can be used in main?


A. True
B. False
C. True if it is declared static
D. None of the mentioned

Explanation:
Since the scope of the variable declared within a function is restricted only within that function,
the above statement is false.

14. The name of the variable used in one function cannot be used in another function?


A. True
B. False
C. May be
D. None of the mentioned.

Explanation:
Since the scope of the variable declared within a function is restricted only within that function, the same name can be used to declare another variable in another function.

15. C99 standard guarantees uniqueness of __ characters for internal names.

A. 31
B. 63
C. 12
D. 14

Explanation:
ISO C99 compiler may consider only first 63 characters for internal.

16. Which of the following is not a valid variable name declaration?


A. int __a3;
B. int __3a;
C. int __A3;
D. None of the mentioned.

17. Variable name resolving (number of significant characters for uniqueness of variable) depends on?

A.Compiler and linker implementations
B. Assemblers and loaders implementations
C. C Language
D. None

Explanation:
It depends on the standard to which compiler and linkers are adhering to.

18. Which of the following is not a valid C variable name?


A. int number;
B. float rate;
C. int variable_count;
D. int $main;

Explanation:
Since only underscore and no other special character is allowed in a variable name, it results in an error.

19. Which is valid C expression?


A. int my_num = 100,000;
B. int my_num = 100000;
C. int my num = 1000;
D. int $my_num = 10000;

Explanation:
space, comma and $ cannot be used in a variable name.

20. What is the output of this C code?

int main()
{
int y = 10000;
int y = 34;
printf(“Hello World! %d\n”, y);
return 0;
}


A. Compile time error
B. Hello World! 34

Explanation:
Since y is already defined, redefining it results in an error.

21. Which of the following is not a valid variable name declaration?


A. float PI = 3.14;
B. double PI = 3.14;
C. int PI = 3.14;
D. #define PI 3.14

Explanation:
define PI 3.14 is a macro preprocessor, it is a textual substitution.

22. Which of the following cannot be a variable name in C?


A. Volatile
B. True
C. friend
D. export

23. What is the output of this C code?

int main()
{
void foo();
void f()
{
foo();
}
f();
}
void foo()
{
printf(“2 “);
}

A. 2 2
B. 2
C. Compile time error
D. Depends on the compiler

Explanation:
Even though the answer is 2, this code will compile fine only with gcc. GNU C supports nesting of functions in C as a language extension where as standard C compiler doesn’t.

24. What is the output of this C code?

int main()
{
int a = 0, i = 0, b;
for (i = 0;i < 5; i++)
{
a++;
continue;
}
}


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

25. What is the output of this C code?

void main()
{
double k = 0;
for (k = 0.0; k < 3.0; k++)
printf(“Hello”);
}


A. Run time error
B. Hello is printed thrice
C. Hello is printed twice
D. Hello is printed infinitely

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 Programming Questions | TCS Coding Questions 2021 Set 3: Click here

TCS NQT 2020 Coding Questions With Answers | TCS NQT Programming Logic Questions Set 4: 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 JobClick 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

LEAVE A REPLY

Please enter your comment!
Please enter your name here