TomoLink
TCS NQT GuideTCS NQT Programming Logic & CS FundamentalsData Types, Operators, and Input-Output Basics (C/C++)

Data Types, Operators, and Input-Output Basics (C/C++)

Learn core concepts, essential formulas, and attempt practice questions designed on the latest TCS NQT testing patterns.

Key Concepts & Formulas

  • 1Data type sizes: char (1 byte), int (4 bytes on 32/64 bit systems), float (4 bytes).
  • 2Operators priority: Post/Pre increments have high priority.
  • 3Printf returns the number of characters printed successfully.

TCS NQT Style Practice Questions

Practice Question 1

What is the output: printf("%d", printf("TCS"));

A) TCS3
B) TCS
C) 3
D) TC3

Correct Answer: A) TCS3

Step-by-step Solution: The inner printf runs first, outputting the string 'TCS'. It returns 3 (number of characters). The outer printf then prints this return value (3). Combined output: TCS3.

Practice Question 2

What is value of x: int x = 5; x = x++ + ++x;

A) 12
B) 11
C) 13
D) Undefined behavior

Correct Answer: D) Undefined behavior

Step-by-step Solution: Modifying a variable multiple times within a single sequence point (x = x++ + ++x) leads to undefined behavior in standard C/C++.

Study Pro-Tip

Understand prefix vs postfix. Postfix increments value after returning it; prefix increments immediately.