Bird
0
0

You want to print a multiplication table from 1 to 5 using nested loops. Which code snippet correctly achieves this?

hard📝 Application Q8 of 15
C - Loops
You want to print a multiplication table from 1 to 5 using nested loops. Which code snippet correctly achieves this?
Afor(int i=1; i<=5; i++) { for(int j=1; j<=5; j++) printf("%d ", i+j); printf("\n"); }
Bfor(int i=1; i<=5; i++) { for(int j=1; j<=5; j++) { printf("%d ", i-j); } printf("\n"); }
Cfor(int i=1; i<=5; i++) { for(int j=1; j<=5; j++) { printf("%d ", i*j); } printf("\n"); }
Dfor(int i=1; i<=5; i++) { for(int j=1; j<=5; j++) { printf("%d ", i/j); } printf("\n"); }
Step-by-Step Solution
Solution:
  1. Step 1: Understand multiplication table logic

    Each cell is product of row and column numbers (i*j).
  2. Step 2: Check code snippets for correct calculation

    Only for(int i=1; i<=5; i++) { for(int j=1; j<=5; j++) { printf("%d ", i*j); } printf("\n"); } prints i*j; others print sums, differences, or divisions.
  3. Final Answer:

    for(int i=1; i<=5; i++) { for(int j=1; j<=5; j++) { printf("%d ", i*j); } printf("\n"); } -> Option C
  4. Quick Check:

    Multiplication table needs i*j product [OK]
Quick Trick: Multiply indices for multiplication table [OK]
Common Mistakes:
  • Using addition or subtraction instead of multiplication
  • Forgetting newline after each row

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes