Previous Next
0 / 33
Module DEMO-32-60DEMO-C-32

Square of Numbers (Repeating Cols)

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Problem Description

Write a program that reads an integer N and prints a square pattern with N rows and N columns. Each row contains the same number repeated N times. The number starts at 1 for the first row and increases by 1 for each subsequent row.


Constraints

You must use nested loops to solve this problem.

Input Format

A single integer N where 1 <= N <= 20.

Output Format

N rows of numbers, each row containing N copies of the row number separated by spaces.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
3
1 1 1
2 2 2
3 3 3
Input: 3
Sample #2
Public sample
5
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
Input: 5
Sample #3
Public sample
1
1
Input: 1
Sample #4
Public sample
7
1 1 1 1 1 1 1
2 2 2 2 2 2 2
3 3 3 3 3 3 3
4 4 4 4 4 4 4
5 5 5 5 5 5 5
6 6 6 6 6 6 6
7 7 7 7 7 7 7
Input: 7

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings