Number Guessing Game - Xiao-XC/C-Practice-Projects GitHub Wiki

Number-Guessing-Game

Type: Bro Code course project Date: Sept 2026 Concepts: rand(), srand(time(NULL)), do-while, tracking state across iterations

What it does

Generates a random number from 1 to 100 and lets the user guess it, with too-high / too-low feedback and a tries counter.

What I learned

This was the first bug I found and fixed myself: my random-range formula could produce values outside 1 to 100. After fixing it I traced the math and realized the fix only worked because min was 1. The general version is min + rand() % (max - min + 1). The lesson is to test edge cases, not just the happy path.

Source

[View the code on GitHub](https://github.com/Xiao-XC/C-Practice-Projects/tree/main/Number-Guessing-Game)

Back to Home