Professional Documents
Culture Documents
Computer Science Assignment: Omi Wankhede Class: XI A Roll No: 26
Computer Science Assignment: Omi Wankhede Class: XI A Roll No: 26
SCIENCE
ASSIGNMENT
1
ACKNOWLEDGEMENT
2
CONTENTS
i. Introduction 4
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();
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;
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];
}
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.
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
Initialize 2 array
(1- words, 1-jumbled word) True Level=2? False
Initialize 2 array
(1- words, 1-jumbled word) True Level=3? False
Exit A
17
D
Score = 0, i = 0
i<5? Yes
Exit A
Read user’s guess word
No. of characters
No of jumbled word Yes
& guess word
are equal?
Score = Score +1
i = i+1 Print Score
No
Score
i = i+1
=5?
Yes
Exit A 18
CLOSURE
Thank you
19
BIBLIOGRAPHY
CLASS XI COMPUTER TEXTBOOK
google.com
quora.com
20