Previous Next
0 / 18
Module DEMO-32-91DEMO-C-32

Print a Negative Number Box

DEMO-C-32 • Programming in C

Browser-only practice

Problem Statement

Given an integer n, print an n x n box where every row contains the negative numbers from -1 to -n, separated by a single space.

For example, if n = 3, the output should be:

-1 -2 -3

-1 -2 -3

-1 -2 -3

The program must print exactly n lines, and each line must contain exactly n numbers.

Constraints

1 <= n <= 100 The output must match the required format exactly. Do not print extra spaces at the end of a line. Do not print extra blank lines.

Input Format

A single integer n.

  • n represents the size of the box.

Output Format

Print n lines.

  • Each line must contain the numbers -1 through -n separated by a single space.
  • Repeat the same line exactly n times.

Sample Testcases

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

Sample #1
Public sample
1
-1
Smallest valid box size.
Sample #2
Public sample
2
-1 -2
-1 -2
Verifies two rows and correct spacing.
Sample #3
Public sample
3
-1 -2 -3
-1 -2 -3
-1 -2 -3
Sample box of size three.
Sample #4
Public sample
6
-1 -2 -3 -4 -5 -6
-1 -2 -3 -4 -5 -6
-1 -2 -3 -4 -5 -6
-1 -2 -3 -4 -5 -6
-1 -2 -3 -4 -5 -6
-1 -2 -3 -4 -5 -6
Checks another distinct size and completes grading weight coverage.

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