Skip to content

This C language project implements a 4-digit number guessing game with interactive hints and colored console output. It focuses on basic programming concepts, random number generation, and digit manipulation without arrays.

Notifications You must be signed in to change notification settings

gobstech/guessing-game-c

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

🎯 Number Guessing Game in C

Language Platform License Status


📄 Project Overview

This project implements a number guessing game in the C programming language, designed to reinforce fundamental programming concepts.
The game randomly generates a 4-digit secret number (between 1000 and 9999), and the player has 10 attempts to guess it correctly.

After each guess, the program provides feedback on how many digits are correct and in the correct position.
Starting from the fifth attempt, the game introduces progressive hints to assist the player, such as digit parity (even/odd) and comparison to the number 5.
At the end of each round, the player can choose to restart or exit the game.

Developed by João Paulo Nunes Andrade, Caíque Andraus, Gabriel Oliveira, and João Victor Neder.


🧠 Implemented Features

  • 🔢 Secret Number Generation – Uses rand() and srand(time(NULL)) from <stdlib.h> and <time.h> to generate a random 4-digit number
  • 🎯 Limited Attempts – Players have up to 10 chances to guess the correct number
  • 📊 Feedback System – Displays how many digits are correct and in the correct position after each guess
  • 💡 Hint System – From the 5th attempt onward, provides hints such as:
    • Parity (even or odd)
    • Comparison (greater than or less than/equal to 5)
  • 🎨 Interactive Interface – Uses ANSI color macros (#define RED, #define GRN, #define YEL) to highlight messages and improve user experience
  • 🔁 Restart Option – Allows the player to choose whether to play again after each game

⚙️ Technical Highlights

  • Language: C (standard libraries only)
  • Digit Manipulation: Uses division (/) and modulo (%) to extract and compare digits
  • Control Structures: if, while, do-while for game logic and input validation
  • Localization: setlocale(LC_ALL, "Portuguese") from <locale.h> for proper character display
  • Console Management: system("cls") and system("pause") for screen clearing and user flow (OS-dependent)

▶️ How to Run

  1. Save the code as game.c
  2. Compile using GCC:
    gcc game.c -o game
    

📬 Contact Me

About

This C language project implements a 4-digit number guessing game with interactive hints and colored console output. It focuses on basic programming concepts, random number generation, and digit manipulation without arrays.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 100.0%