006-002-013

Nested For Loops (Multiplication Table)

Medium

Problem Description

Nested For Loops (Multiplication Table)

In this problem, you will create a program that reads an integer n from standard input, uses nested for loops to control rows (1–n) and columns (1–n), computes the product of each pair, and displays an n×n multiplication table with values separated by spaces to standard output.

Learning Objective: Understand 2D repetitive processing with nested for loops

Overview

Placing a for loop inside another enables row-column 2D processing. A multiplication table is a classic example.

Input Format

n
  • n: size of the table (positive integer)

Specifications

  • Outer for controls rows (1–n), inner for controls columns (1–n)
  • Display calculation results for each row separated by spaces

Sample Input

3

Sample Output

1 2 3
2 4 6
3 6 9

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up