
Learn core concepts, essential formulas, and attempt practice questions designed on the latest TCS NQT testing patterns.
How many stars print for: for(i=1;i<=3;i++) for(j=1;j<=i;j++) print('*')?
Correct Answer: A) 6
Step-by-step Solution: i=1: j runs 1 time. i=2: j runs 2 times. i=3: j runs 3 times. Total prints = 1 + 2 + 3 = 6 stars.
What loop condition prints a right-angled triangle?
Correct Answer: A) Inner loop terminates at outer variable value
Step-by-step Solution: To print incrementing counts per row, the column loop must terminate at the current row index (j <= i).
Draft row-column indices tables on grids to find exact line spaces formulas.