0% found this document useful (0 votes)
75 views21 pages

Computer Science Assignment: Omi Wankhede Class: XI A Roll No: 26

This document describes a word guessing game program created in C++. The program allows the user to choose between three categories (fruit, animal, country) and three difficulty levels within each category. For each level, there are 5 correct words and their jumbled versions. The user has 5 attempts to guess the jumbled words. The program tracks the user's score and provides feedback on correct or incorrect guesses. Flowcharts and code snippets are included to explain the program logic and implementation.

Uploaded by

omiwankhede
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views21 pages

Computer Science Assignment: Omi Wankhede Class: XI A Roll No: 26

This document describes a word guessing game program created in C++. The program allows the user to choose between three categories (fruit, animal, country) and three difficulty levels within each category. For each level, there are 5 correct words and their jumbled versions. The user has 5 attempts to guess the jumbled words. The program tracks the user's score and provides feedback on correct or incorrect guesses. Flowcharts and code snippets are included to explain the program logic and implementation.

Uploaded by

omiwankhede
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

COMPUTER

SCIENCE
ASSIGNMENT

Omi Wankhede Class: XI A Roll No: 26


THE
WORD
GUESSING
GAME

1
ACKNOWLEDGEMENT

I would like to express our special thanks of gratitude to my


computer science teacher, Divya ma’am, as well as our
principal who gave us the opportunity to do this wonderful
project, making a game with the help of c++, which also
helped me in performing a lot of research and I came to
know about so many new things. I am really thankful to
them.

2
CONTENTS

Sr. No. Topic Pg. No.

i. Introduction 4

ii. Project Code 5-9

iii. Output 10-14

iv. Flowchart 15-18

v. Closure 19

vi. Bibliography 20

3
INTRODUCTION
This assignment is about c++ programming and how it can be
turned into a fun experience by creating small and easy-to-make
enjoyable games. The programmers can create their own games
or programs meeting their own requirements. This assignment
consists the game “The Word Guessing Game” in which the user-
player has five chances to guess the correct word from some
jumbled words, if he/she fails in doing so, they will lose the game
and the game will start all over again with some other jumbled
words. The player can choose between three categories and three
levels of different difficulties in each category. This game was
executed in turbo c++ and was confirmed ready to play with zero
errors. I have created this program by my own with some help
from the internet. In this path, I came across a lot of problems but
hard work always bears a fruit.

4
PROJECT
CODE

5
// for input, output
#include<iostream.h>
// for string function like strlen, strcmp
#include<string.h>
// for clrscr and getch function
#include<conio.h>
// gets() function to read string
#include<stdio.h>

char userword[7];
int category, level;
void calScore(char w[5][20],char w1[5][20]);

void main()
{
start:
clrscr();

char answer = 'N';


cout<<"select category by entering its number" <<"\n";
cout<<"1. Fruit" <<"\n";
cout<<"2. Animal" <<"\n";
cout<<"3. Country" <<"\n";
cin>>category;

switch(category)
{
case 1:
cout<<"select level by entering its number" <<"\n";
cout<<"1. Easy" <<"\n";
cout<<"2. Medium" <<"\n";
cout<<"3. Difficult" <<"\n";
cin>>level;
if(level==1)
{ // create 2 array of words per category per
level, 1 for correct words and 1 for jumbled words
char efruit[5][20] = {"apple", "kiwi", "pear",
"mango", "plum"};
char ejfruit[5][20] = {"palpe", "wiik",
"repa", "gamon", "lmpu"};
calScore(ejfruit, efruit);
} else if(level==2)
{
char mfruit[5][20] = {"peach",
"avocodo","grape","lychee", "pineapple" };
char mjfruit[5][20] = {"hacep", "dooacov",
"repga","ehecyl", "palpeiepn" };
calScore(mjfruit, mfruit);
} else if(level==3)
{
char dfruit[5][20] = {"pomegranate",
"dragonfruit", "gooseberries", "muskmelon", "mulberry"};

6
char djfruit[5][20] =
{"aanetrgmope","ofdurigtnra", "rgoseoiesebr", "soslnkumm",
"rmurlrby"};
calScore(djfruit, dfruit);
} else
{
cout<<"\n"<<"Please select the proper
number"<<"\n";
}
break;
case 2:
cout<<"select level by entering its number" <<"\n";
cout<<"1. Easy" <<"\n";
cout<<"2. Medium" <<"\n";
cout<<"3. Difficult" <<"\n";
cin>>level;
if(level==1)
{
char eanimal[5][20] = {"fox", "cow", "wolf",
"lion", "deer"};
char ejanimal[5][20] = {"xfo",
"owc", "lfow", "noli", "edre"};
calScore(ejanimal, eanimal);
} else if(level==2)
{
char manimal[5][20] = {"tiger", "hyena",
"monkey", "panda", "cheeta"};
char mjanimal[5][20] = {"egrit",
"nyahe", "onmeyk", "aandp", "taeech"};
calScore(mjanimal, manimal);
} else if(level==3)
{
char danimal[5][20] = {"elephant", "jaguar",
"chimpanzee", "giraffe", "reindeer"};
char djanimal[5][20] = {"tnahpele",
"ragjua", "ezpenaihcm", "efirafg", "edreinre"};
calScore(djanimal, danimal);
} else
{
cout<<"\n"<<"Please select the proper
number"<<"\n";
}
break;

case 3:
cout<<"select level by entering its number" <<"\n";
cout<<"1. Easy" <<"\n";
cout<<"2. Medium" <<"\n";
cout<<"3. Difficult" <<"\n";
cin>>level;
if(level==1)
{

7
char ecountry[5][20] = {"canada", "china",
"japan", "nepal", "iraq"};
char ejcountry[5][20] = {"aaadnc",
"inhca", "pnaaj", "enlpa", "rqia"};
calScore(ejcountry, ecountry);
} else if(level==2)
{
char mcountry[5][20] = {"russia", "chile",
"korea", "srilanka", "burma"};
char mjcountry[5][20] = {"ssuiar",
"ilceh", "earok", "aaknrils", "rmaub"};
calScore(mjcountry, mcountry);
} else if(level==3)
{
char dcountry[5][20] = {"singapore",
"yugoslavia", "afghanistan", "uganda", "czechoslovakia"};
char djcountry[5][20] = {"garepoins",
"goaaviuysl", "nastghfania", "adangu", "zakiavslocohce"};
calScore(djcountry, dcountry);
} else
{
cout<<"\n"<<"Please select the proper
number"<<"\n";
}
break;

default: cout<<"Please select proper category number"<<"\n";


}

cout << "Do you want to continue (Y/N)?\n";


cout << "You must type a 'Y' or an 'N' :";
cin >> answer;
if((answer == 'Y') || (answer == 'y'))
{
goto start;
}
else
{
return ;
}

getch();
return ;
}
void calScore(char w[5][20],char w1[5][20])
{ int score=0;
for(int i=0; i<5; i++)
{ cout<<"\n"<<"Jumbled word is: ";
for(int j=0; j<strlen(w[i]); j++)
{

8
cout<<w[i][j];
}

cout<<"\n"<<"Enter your guess : ";


gets(userword);
if(strlen(userword)!=strlen(w[i]))
{
cout<<"\n"<< "Please check for number of
letters entered"<<"\n";
i=i-1;
}

if(strcmp(w1[i],userword)==0)
{ score=score+1;

cout<<"\n"<<"Congrualations...............you won!!";
if(score==5)
{
cout<<"\n"<<"Wow !! You complete the level
with highest score !"<<"\n";
}
}
else
{
cout<<"\n"<<"Wrong Answer!"<<"\n";
}
cout<<"\n"<<"your score is : " <<score
<<"\n\n";
}
}

END

9
OUTPUT

10
THE MAIN MENU: Here you can choose between three categories.

THE LEVELS: Here you can choose between three levels.

11
CATEGORY:Fruit LEVEL:Easy

Congratulations message is displayed after giving correct answer.Score is displayed after every
attempt.

12
When you answer five questions correctly,high score message is displayed.After five attempts,you are
asked whether you want to continue or not.If you type ‘N’, then the window is closed.

13
If you type ‘Y’, then previous screen is cleared and return to the main menu.

If the guess is wrong, then wrong answer message is displayed.If the number of letters used are
wrong, then you are informe

14
FLOWCHART

15
Start

Read Category
1. Fruit 2. Animal 3. Country

True
Case 1 A

False

True
Case 2 B

False

True
Case 3 C

False

Default Case

Print message to
select valid category

Yes Want to
continue?

No

16
Stop
(Note: Flowchart will be same for B and C Connector)

Read level
1-Easy,2- Medium,3-Difficult

True Level=1? False

Initialize 2 array
(1- words, 1-jumbled word) True Level=2? False

Initialize 2 array
(1- words, 1-jumbled word) True Level=3? False

Initialize 2 array Print message to select


valid level
(1- words, 1-jumbled word)

Exit A

Call function and pass 2 array to it as per level

17
D

Score = 0, i = 0

i<5? Yes

No Print jumbled word

Exit A
Read user’s guess word

No. of characters
No of jumbled word Yes
& guess word
are equal?

Print “check no. of


character” Both
No Yes
words
same?
i = i-1
Print “Wrong Print “you won”
answer”

Score = Score +1
i = i+1 Print Score

No
Score
i = i+1
=5?

Yes

Print “Level Complete”

Exit A 18
CLOSURE

Making a project is a good way to gain knowledge. By performing


this project, I came to know how a game can be created and
modified in your own way with the help of c++. I would like to
thank my teacher for giving me the opportunity to work on this
project and I assure that the knowledge I gained from this project
will help us further in our studies and careers. I’ve tried my best to
make this project understandable to other users and fellow
programmers and I apologize for any kind of discrepancies.

Thank you

19
BIBLIOGRAPHY
 CLASS XI COMPUTER TEXTBOOK
 google.com
 quora.com

20

You might also like