Random Number Memory Game in C Last Updated : 28 Apr, 2021 Summarize Comments Improve Suggest changes Share 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 infoAdvertise with us Next Article Memory Layout of C Programs O onlyklohan Follow Improve Article Tags : C Language Similar Reads Pacman Game in C Making projects is one of the most interesting and fun ways to learn a programming language such as C. In this article, we will learn how to write code for the Pacman game in C. What is Pacman Game?Pacman Game is a classic arcade video game that was first released in 1980 by Namco (formerly known as 5 min read Common Memory/Pointer Related bug in C Programs Dereferencing an unknown memory location : C programmers mostly use scanf() function to take input, but sometimes a small mistake can bring a bug or even crash whole program. The syntax for scanf() is scanf("%d", &a);. It might be possible to miss a & and write &a as a so now scanf("%d", 6 min read Snake and Ladder Game in C Snake and Ladder game is a traditional game that involves two or more players and the winner is the guy who reaches the final square on the game board at the earliest. Components of the GameA square board with a series of numbered squares arranged in m x m grid.A dice to be rolled usually uses a six 5 min read Memory Layout of C Programs The memory layout of a program refers to how the programâs data is stored in the computer memory during its execution. Understanding this layout helps developers manage memory more efficiently and avoid issues such as segmentation faults and memory leaks.A C program's memory is organized into specif 5 min read Guess Game using rand() and srand() in C Using srand() and rand() function in C, a simple but interesting game can be made. This game is called "Guess Game" . Rules of the Game : There are three holes . A rat is hidden in one of those three holes.The Rat shuffles its position every time.You have to guess the hole in which the Rat is hidden 3 min read Deleting Memory in C In C programming, we might allocate memory dynamically for various tasks but what happens when those pieces of memory are no longer needed? If not managed properly, they can lead to memory leaks, wasting valuable resources, and slowing down our program. Therefore, we need to manage memory in C by pr 5 min read Like