What is the output of the following code? int main() {
What is the output of the following code?
#include <stdio.h>
int main() {
for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= i; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
Show answerHide answer
Correct answer: (A) * ** ***
Explanation
The outer loop runs i = 1 to 3, and the inner loop prints i stars each time, so the rows are *, ** and ***.