Important MCQ

Output? (right-aligned triangle) for (int i = 1; i <= 3; i++) { for (int j = 1; j <= 3 - i; j++) cout << " "; for (int k = 1; k <= i; k++) cout << "*"; cout << endl; }

Q.Output? (right-aligned triangle) for (int i = 1; i <= 3; i++) { for (int j = 1; j <= 3 - i; j++) cout << " "; for (int k = 1; k <= i; k++) cout << "*"; cout << endl; }

A) Left-aligned triangle (*, **, ***)
B) Right-aligned triangle (*, **, ***)
C) Inverted triangle
D) Square of stars
Correct Answer:
Option B
Detailed Explanation:
Row 1: 2 spaces + 1 star; row 2: 1 space + 2 stars; row 3: 3 stars.