https://github.com/manvith12/spiralprinter
A c program which prints a spiral of any side length
https://github.com/manvith12/spiralprinter
Last synced: about 2 months ago
JSON representation
A c program which prints a spiral of any side length
- Host: GitHub
- URL: https://github.com/manvith12/spiralprinter
- Owner: manvith12
- Created: 2024-11-05T18:25:32.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-11-05T18:38:59.000Z (7 months ago)
- Last Synced: 2025-02-13T21:46:16.779Z (3 months ago)
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spiral Grid Pattern
This program creates a square grid (like a chessboard) and fills it with a spiral pattern. It then prints the grid using stars (`*`) and spaces.
## Overview
1. **Ask for a Number**: The program starts by asking for a number, `N`. This number determines the size of the grid. For example, if you enter `5`, the grid will be `5 rows by 5 columns`.
2. **Create the Grid**: The program initializes an empty grid with `N` rows and `N` columns. Initially, all spots in the grid are set to `0`.
3. **Draw the Spiral**:
- The program starts at the top-left corner of the grid.
- It moves right, then down, then left, and then up, creating a spiral shape.
- Each time it moves, it changes the `0` in the grid to a `1` to mark the path of the spiral.4. **Print the Grid**:
- The program iterates through each spot in the grid.
- If the spot has a `1`, it prints a space (` `).
- If the spot has a `0`, it prints a star (`*`).## Example
If you enter `50`, the program will create a `50x50` grid and fill it with a spiral pattern. The output will look like this:
