Skip to content
Programming101
Programming101

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programming101

Learn everything about programming

C++ program to create a game [Find Hidden Word]

YASH PAL, 31 July 202422 August 2024

In this post, we will write a C++ program to create a game [Find Hidden Word]. The first user will enter a word that is not more than 10 characters long. after that in that he will enter a character and the program will check if that character is available in the word. if the character is available then the program will print that character. as you could see in the below given image in output section 

C++ program to create a game [Find Hidden Word]

C++ program to create a game [Find Hidden Word]

#include<iostream>
#include<conio.h>
#include<windows.h>

BOOL gotoxy(const WORD x, const WORD y) {
    COORD xy;
    xy.X = x;
    xy.Y = y;
    return SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), xy);
}


int main()
{
    system("cls");

    char a[10],b[10];
    int i,n,j,k,p,no;

    std::cout<<"Enter the word of maximum ten characters = ";
    std::cin>>a;

    system("cls");

    k=0;

    while(a[k] != '')
    {
        gotoxy(40+k,3);
        std::cout<<"-";
        k++;
    }

    no = k*2;
    gotoxy(70,1);
    std::cout<<no;
    p=0;

    for(int m=1;m<=2;m++)
    {
        i=0;

        while(a[i] != '')
        {
            gotoxy(1,1);
            std::cout<<"Enter any character = ";
            b[i] = getch();

            if(b[i] == a[0])
            {
                gotoxy(40,3);
                std::cout<<b[i]<<std::endl;
                p++;
            }
            if(b[i] == a[1])
            {
                gotoxy(41,3);
                std::cout<<b[i]<<std::endl;
                p++;
            }
            if(b[i] == a[2])
            {
                gotoxy(42,3);
                std::cout<<b[i]<<std::endl;
                p++;
            }
            if(b[i] == a[3])
            {
                gotoxy(43,3);
                std::cout<<b[i]<<std::endl;
                p++;
            }
            if(b[i] == a[4])
            {
                gotoxy(44,3);
                std::cout<<b[i]<<std::endl;
                p++;
            }
            if(b[i] == a[5])
            {
                gotoxy(45,3);
                std::cout<<b[i]<<std::endl;
                p++;
            }
            if(b[i] == a[6])
            {
                gotoxy(46,3);
                std::cout<<b[i]<<std::endl;
                p++;
            }
            if(b[i] == a[7])
            {
                gotoxy(47,3);
                std::cout<<b[i]<<std::endl;
                p++;
            }
            if(b[i] == a[8])
            {
                gotoxy(48,3);
                std::cout<<b[i]<<std::endl;
                p++;
            }
            if(b[i] == a[9])
            {
                gotoxy(49,3);
                std::cout<<b[i]<<std::endl;
                p++;
            }
            no--;
            gotoxy(70,1);
            std::cout<<no;
            i++;
            gotoxy(1,1);
        }
    }

    std::cout<<"Your correct sentence = "<<a;

    getch();
    return 0;
}

Output

C++ program to create a game [Find Hidden Word]

coding problems cpp

Post navigation

Previous post
Next post
  • HackerRank Separate the Numbers solution
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
©2025 Programming101 | WordPress Theme by SuperbThemes