Random Number Memory Game in C Last Updated : 15 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In this article, will design a simple number memory game in the C programming language. It is a simple memory number game where a random number is displayed and is hidden after some time. The task is to guess that displayed number to continue the game. How to Play This Game: Press 1 on your keyboard to start the game.A random positive number is displayed in the console which the player has to remember.After few seconds the number displayed will disappear.At the next line in the console, the player has to input the number shown previously.If the input number is the same as the previous number then the player's score increases by 1 and the game continue.If the input number is incorrect, the game ends and the player's score is displayed. Below is the implementation of the above approach: C // C program to implements the above // memory game #include <conio.h> #include <dos.h> #include <stdio.h> #include <stdlib.h> // Function to generate the random // number at each new level int randomnum(long level) { clrscr(); printf("Level %ld \n", level); long num; num = (rand() % 100 * level) + 1 + level * 5.2f; printf("Number : %ld \n", num); delay(2000 - (10 * level)); clrscr(); // Return the number return num; } // Driver Code void main() { clrscr(); long num; long guessnum; long level = 1; long inputnum; // Start the game printf("Press 1 to start Game! "); scanf("%ld", &inputnum); // Game Starts if (inputnum == 1) { // Iterate until game ends do { // Generate a random number num = randomnum(level); // Get the guessed number scanf("%ld", &guessnum); level++; // Condition for the Game // Over State if (guessnum != num) { printf("You Failed! "); } } while (num == guessnum); } getch(); } Output: Comment More info O onlyklohan Follow Improve Article Tags : C Language Explore C BasicsC Language Introduction6 min readIdentifiers in C3 min readKeywords in C2 min readVariables in C4 min readData Types in C5 min readOperators in C8 min readDecision Making in C (if , if..else, Nested if, if-else-if )7 min readLoops in C6 min readFunctions in C6 min readArrays & StringsArrays in C6 min readStrings in C6 min readPointers and StructuresPointers in C9 min readFunction Pointer in C6 min readUnions in C4 min readEnumeration (or enum) in C5 min readStructure Member Alignment, Padding and Data Packing8 min readMemory ManagementMemory Layout of C Programs5 min readDynamic Memory Allocation in C7 min readWhat is Memory Leak? How can we avoid?2 min readFile & Error HandlingFile Handling in C11 min readRead/Write Structure From/to a File in C3 min readError Handling in C8 min readUsing goto for Exception Handling in C4 min readError Handling During File Operations in C5 min readAdvanced ConceptsVariadic Functions in C5 min readSignals in C language5 min readSocket Programming in C8 min read_Generics Keyword in C3 min readMultithreading in C9 min read Like