I'm studied and learned C-Language on my own. This is a memory game I created. Copy and paste it to Notepad and save as <filename>.c then open it with Turbo C. Enjoy!
=============================================

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<time.h>

#define KEY_UP 72
#define KEY_DOWN 80
#define KEY_RIGHT 77
#define KEY_LEFT 75
#define KEY_RETURN 13
#define KEY_ESC 27

int score=0,COL=6,ROW=3,ROW1=0,COL1=0,ROW2=0,COL2=0;
int a=1,b=1,c=0,h=0,j=0,n=0,o=0,w=0,y=0,z=0,cols=0,row s=0;
int ctr=0,f[17][17]={0},g[17][17]={0};

main()
{
int choice,error;
char query;

clrscr();
textbackground(BLACK);
textcolor(LIGHTBLUE);
gotoxy(25,2);
cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
gotoxy(25,3);
cprintf("ÛÛ Memory Game v1.3 ÛÛ");
gotoxy(25,4);
cprintf("ÛÛßßßßßßßßßßßßßßßßßßßßßÛÛ");
gotoxy(25,5);
cprintf("ÛÛ 1. New Game ÛÛ");
gotoxy(25,6);
cprintf("ÛÛ 2. Instructions ÛÛ");
gotoxy(25,7);
cprintf("ÛÛ 3. Credits ÛÛ");
gotoxy(25,8);
cprintf("ÛÛ 4. Version History ÛÛ");
gotoxy(25,9);
cprintf("ÛÛ 5. Exit ÛÛ");
gotoxy(25,10);
cprintf("ÛÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛÛ");
gotoxy(25,11);
cprintf("ÛÛ Enter your choice: ÛÛ");
gotoxy(25,12);
cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
gotoxy(46,11);
scanf("%d",&choice);
scanf("%c",&error);
switch(choice)
{
case 1:
difficulty();
break;
case 2:
textcolor(LIGHTBLUE);
gotoxy(25,13);
cprintf("I N S T R U C T I O N S");
gotoxy(12,15);
cprintf("Using the arrow keys, select the box you want to flip.");
gotoxy(12,16);
cprintf("Press Enter key to determine your choice.");
gotoxy(12,17);
cprintf("Try to find a matching symbol to the corresponding box.");
gotoxy(12,18);
cprintf("Press X any time during the game to quit.");
gotoxy(12,19);
cprintf("Press R any time during the game to restart.");
gotoxy(12,20);
cprintf("Press Esc any time during the game to go back.");
gotoxy(12,21);
cprintf("Press any key to go back to main menu during the scrolling credits.");
gotoxy(12,23);
cprintf("Press any key to go back...");
getch();
main();
break;
case 3:
credits();
break;
case 4:
textcolor(GREEN);
clrscr();
gotoxy(25,1);
cprintf("Memory Game");
gotoxy(35,2);
cprintf("by: Johnny 'Jazy' Cheng");
gotoxy(25,4);
cprintf("Version history");
gotoxy(1,5);
cprintf("Version 1.0");
gotoxy(1,6);
cprintf("-Created a simple game of Memory with simple menu.");
gotoxy(1,7);
cprintf("-Used the arrow keys and return key to input the moves.");
gotoxy(1,8);
cprintf("-Fixed the limit bug in the game.");
gotoxy(1,9);
cprintf("-Fixed the scoring bug.");
gotoxy(1,10);
cprintf("-Fixed the winning condition error.");
gotoxy(1,11);
cprintf("Version 1.1");
gotoxy(1,12);
cprintf("-Added a nice menu box layout and the credits and instructions menu.");
gotoxy(1,13);
cprintf("-Also added a new difficulty menu.");
gotoxy(1,14);
cprintf("-Also added the X key to exit any time during the game.");
gotoxy(1,15);
cprintf("-Fixed the character bug and the exit bug in the menus.");
gotoxy(1,16);
cprintf("-Added the try again feature.");
gotoxy(1,17);
cprintf("-Improved the difficulty of the Easy Mode.");
gotoxy(1,18);
cprintf("Version 1.2");
gotoxy(1,19);
cprintf("-Changed the menu box layout.");
gotoxy(1,20);
cprintf("-Also added some humor in the program.");
gotoxy(1,21);
cprintf("-Also added the R key to reset anytime during the game.");
gotoxy(1,22);
cprintf("-Also added the Esc key to go back to difficulty menu during the game.");
gotoxy(1,23);
cprintf("-Also added the scrolling credits.");
gotoxy(1,24);
cprintf("-Finished the Medium difficulty level feature.");
gotoxy(1,25);
cprintf("Press any key to go to the next page...");
getch();
clrscr();
gotoxy(1,1);
cprintf("Version 1.3");
gotoxy(1,2);
cprintf("-Finished the Hard difficulty level feature.");
gotoxy(1,3);
cprintf("-Added color in the entire program.");
gotoxy(1,4);
cprintf("-Also added the Press any key to exit feature while the credits are scrolling.");
gotoxy(1,5);
cprintf("-Fixed all the bugs and errors in the program.");
gotoxy(1,6);
cprintf("-Updated all error fixes on all versions of the program.");
gotoxy(1,8);
cprintf("Press any key to go back to the main menu...");
getch();
main();
break;
case 5:
textcolor(LIGHTBLUE);
gotoxy(12,13);
cprintf("The game has just started.");
textcolor(WHITE);
gotoxy(12,14);
cprintf("Are you sure you want to exit?[Y/N] ");
scanf("%c",&query);
switch(toupper(query))
{
case 'Y':
textcolor(LIGHTBLUE);
gotoxy(12,15);
cprintf("Thank you for playing. Press any key to exit...");
getch();
exit(0);
break;
case 'N':
textcolor(LIGHTBLUE);
gotoxy(12,16);
cprintf("Good choice! Press any key to go back...");
getch();
main();
break;
default:
textcolor(RED);
gotoxy(12,16);
cprintf("Invalid Input! Press any key to try again...");
getch();
main();
break;
}
break;
default:
textcolor(RED);
gotoxy(12,13);
cprintf("Invalid choice. Press any key to try again...");
getch();
main();
}
getch();
}

difficulty()
{
int diff;
char error;

clrscr();
textcolor(LIGHTBLUE);
gotoxy(25,2);
cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
gotoxy(25,3);
cprintf("ÛÛ New Game ÛÛ");
gotoxy(25,4);
cprintf("ÛÛßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÛÛ");
gotoxy(25,5);
cprintf("ÛÛ 1. Easy ÛÛ");
gotoxy(25,6);
cprintf("ÛÛ 2. Medium ÛÛ");
gotoxy(25,7);
cprintf("ÛÛ 3. Hard ÛÛ");
gotoxy(25,8);
cprintf("ÛÛ 4. Impossible(Main Menu) ÛÛ");
gotoxy(25,9);
cprintf("ÛÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛÛ");
gotoxy(25,10);
cprintf("ÛÛ Choose a difficulty level: ÛÛ");
gotoxy(25,11);
cprintf("ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ");
gotoxy(54,10);
scanf("%d",&diff);
scanf("%c",&error);
if (diff == 1)
{
easy();
}
else if (diff == 2)
{
medium();
}
else if (diff == 3)
{
hard();
}
else if (diff == 4)
{
textcolor(GREEN);
gotoxy(12,12);
cprintf("You have chosen Impossible...");
gotoxy(12,13);
cprintf("Since this is Impossible, there's no way for you to win.");
gotoxy(12,14);
cprintf("So press any key to go back to main menu...");
getch();
main();
}
else
{
textcolor(RED);
gotoxy(25,12);
cprintf("Invalid Input!");
gotoxy(25,13);
cprintf("Press any key to go back...");
getch();
difficulty();
}
}

easy()
{
char getout,reset;
int move,x=0;

clrscr();
game();
box();
for(n=5;n<36;n+=10)
{
for(o=3;o<7;o++)
{
textcolor(LIGHTBLUE);
gotoxy(n,o);
cprintf("[ ]");
}
}
gotoxy(5,19);
cprintf("Your next move? ");
textcolor(LIGHTGREEN);
gotoxy(5,20);
cprintf("Your score is %d",score);

while (x!=1)
{
textcolor(LIGHTBLUE);
gotoxy(COL,ROW);
move=getch();
if (move == 'X' || move == 'x')
{
textcolor(WHITE);
gotoxy(5,21);
cprintf("Are you sure you want to exit?[Y/N]");
getout=getche();
if (getout == 'Y' || getout == 'y')
{
textcolor(LIGHTBLUE);
gotoxy(5,22);
cprintf("Thank you for playing. Press any key to exit...");
getch();
exit(0);
}
else if (getout == 'N' || getout == 'n')
{
textcolor(LIGHTBLUE);
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
continue;
}
else
{
textcolor(RED);
gotoxy(5,22);
cprintf("Choose only Y for Yes and N for No. Press any key to try again...");
getch();
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(5,22);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,22);
cprintf("ÛÛ");
continue;
}
}
else if (move == 'R' || move == 'r')
{
textcolor(WHITE);
gotoxy(5,21);
cprintf("Are you sure you want to reset the game?[Y/N] ");
reset=getche();
if (reset == 'Y' || reset == 'y')
{
textcolor(LIGHTBLUE);
gotoxy(5,22);
cprintf("The game will restart. Press any key to continue...");
getch();
ctr=0;
score=0;
y=0;
COL=6;
ROW=3;
a=1;
b=1;
for(n=1;n<5;n++)
{
for(o=1;o<5;o++)
{
g[n][o]=0;
}
}
main();
}
else if (reset == 'N' || reset == 'n')
{
textcolor(LIGHTBLUE);
gotoxy(5,21);
clreol();
continue;
}
else
{
textcolor(RED);
gotoxy(5,22);
cprintf("Choose only Y for Yes or N for No. Press any key to go back...");
getch();
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(5,22);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,22);
cprintf("ÛÛ");
continue;
}
}
else if (move == KEY_ESC)
{
textcolor(WHITE);
gotoxy(5,21);
cprintf("Are you sure you want to go back?[Y/N] ");
getout=getche();
if (getout == 'Y' || getout == 'y')
{
textcolor(LIGHTBLUE);
gotoxy(5,22);
cprintf("Press any key to go back...");
getch();
score=0;
ctr=0;
y=0;
COL=6;
ROW=3;
a=1;
b=1;
for(n=1;n<5;n++)
{
for(o=1;o<5;o++)
{
g[n][o]=0;
}
}
difficulty();
}
else if (getout == 'N' || getout == 'n')
{
textcolor(LIGHTBLUE);
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
continue;
}
else
{
textcolor(RED);
gotoxy(5,22);
cprintf("Choose only Y for Yes or N for No.");
getch();
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(5,22);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,22);
cprintf("ÛÛ");
continue;
}
}
else if (move == KEY_RETURN)
{
if (y == 0)
{
textcolor(MAGENTA);
cprintf("%c",f[a][b]);
y=f[a][b];
h=a;
j=b;
ctr+=1;
ROW1=ROW;
COL1=COL;
g[a][b]+=1;
if (g[a][b] == 2)
{
textcolor(RED);
gotoxy(5,21);
cprintf("You have already opened that box.");
getch();
y=0;
ctr-=1;
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(COL,ROW);
}
}
else
{
textcolor(MAGENTA);
cprintf("%c",f[a][b]);
z=f[a][b];
ctr+=1;
g[a][b]+=1;
ROW2=ROW;
COL2=COL;
if (COL2 == COL1)
{
if (ROW2 == ROW1)
{
textcolor(RED);
gotoxy(5,21);
cprintf("You have already opened that box.");
getch();
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
g[a][b]-=1;
g[h][j]-=1;
ctr-=2;
score-=2;
gotoxy(COL2,ROW2);
cprintf(" ");
gotoxy(COL,ROW);
}
}
if (g[a][b] == 2)
{
textcolor(RED);
gotoxy(5,21);
cprintf("You have already opened that box.");
getch();
y=0;
ctr-=2;
g[h][j]-=1;
gotoxy(COL1,ROW1);
cprintf(" ");
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(COL,ROW);
}
else
{
scoring();
if (ctr == 16)
{
textcolor(LIGHTCYAN+BLINK);
gotoxy(5,21);
cprintf("Congratulations! You won!");
functryagain();
}
}
}
}
else if (move == 0)
{
move=getch();
switch(move)
{
case KEY_DOWN:
ROW+=1;
b+=1;
if (b>4)
{
ROW-=1;
b-=1;
}
break;
case KEY_RIGHT:
COL+=10;
a+=1;
if (a>4)
{
COL-=10;
a-=1;
}
break;
case KEY_LEFT:
COL-=10;
a-=1;
if (a<1)
{
COL+=10;
a+=1;
}
break;
case KEY_UP:
ROW-=1;
b-=1;
if (b<1)
{
ROW+=1;
b+=1;
}
break;
default:
textcolor(RED);
gotoxy(5,21);
cprintf("Invalid move. Press any key to continue...");
getch();
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
break;
}
}
}
}

medium()
{
char getout,reset;
int move,x=0;

clrscr();
game();
box();
for(n=5;n<41;n+=5)
{
for(o=3;o<11;o++)
{
textcolor(LIGHTBLUE);
gotoxy(n,o);
cprintf("[ ]");
}
}
gotoxy(5,19);
cprintf("Your next move? ");
textcolor(LIGHTGREEN);
gotoxy(5,20);
cprintf("Your score is %d",score);

while (x!=1)
{
textcolor(LIGHTBLUE);
gotoxy(COL,ROW);
move=getch();
if (move == 'X' || move == 'x')
{
textcolor(WHITE);
gotoxy(5,21);
cprintf("Are you sure you want to exit?[Y/N]");
getout=getche();
if (getout == 'Y' || getout == 'y')
{
textcolor(LIGHTBLUE);
gotoxy(5,22);
cprintf("Thank you for playing. Press any key to exit...");
getch();
exit(0);
}
else if (getout == 'N' || getout == 'n')
{
textcolor(LIGHTBLUE);
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
continue;
}
else
{
textcolor(RED);
gotoxy(5,22);
cprintf("Choose only Y for Yes and N for No. Press any key to try again...");
getch();
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(5,22);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,22);
cprintf("ÛÛ");
continue;
}
}
else if (move == 'R' || move == 'r')
{
textcolor(WHITE);
gotoxy(5,21);
cprintf("Are you sure you want to reset the game?[Y/N] ");
reset=getche();
if (reset == 'Y' || reset == 'y')
{
textcolor(LIGHTBLUE);
gotoxy(5,22);
cprintf("The game will restart. Press any key to continue...");
getch();
ctr=0;
score=0;
y=0;
COL=6;
ROW=3;
a=1;
b=1;
for(n=1;n<9;n++)
{
for(o=1;o<9;o++)
{
g[n][o]=0;
}
}
main();
}
else if (reset == 'N' || reset == 'n')
{
textcolor(LIGHTBLUE);
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
continue;
}
else
{
textcolor(RED);
gotoxy(5,22);
cprintf("Choose only Y for Yes or N for No. Press any key to go back...");
getch();
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(5,22);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,22);
cprintf("ÛÛ");
continue;
}
}
else if (move == KEY_ESC)
{
textcolor(WHITE);
gotoxy(5,21);
cprintf("Are you sure you want to go back?[Y/N] ");
getout=getche();
if (getout == 'Y' || getout == 'y')
{
textcolor(LIGHTBLUE);
gotoxy(5,22);
cprintf("Press any key to go back...");
getch();
y=0;
score=0;
ctr=0;
COL=6;
ROW=3;
a=1;
b=1;
for(n=1;n<9;n++)
{
for(o=1;o<9;o++)
{
g[n][o]=0;
}
}
difficulty();
}
else if (getout == 'N' || getout == 'n')
{
textcolor(LIGHTBLUE);
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
continue;
}
else
{
textcolor(RED);
gotoxy(5,22);
cprintf("Choose only Y for Yes or N for No.");
getch();
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(5,22);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,22);
cprintf("ÛÛ");
continue;
}
}
else if (move == KEY_RETURN)
{
if (y == 0)
{
textcolor(MAGENTA);
cprintf("%c",f[a][b]);
y=f[a][b];
h=a;
j=b;
ctr+=1;
ROW1=ROW;
COL1=COL;
g[a][b]+=1;
if (g[a][b] == 2)
{
textcolor(RED);
gotoxy(5,21);
cprintf("You have already opened that box.");
getch();
y=0;
ctr-=1;
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(COL,ROW);
}
}
else
{
textcolor(MAGENTA);
cprintf("%c",f[a][b]);
z=f[a][b];
ctr+=1;
g[a][b]+=1;
ROW2=ROW;
COL2=COL;
if (COL2 == COL1)
{
if (ROW2 == ROW1)
{
textcolor(RED);
gotoxy(5,21);
cprintf("You have already opened that box.");
getch();
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(ROW2,COL2);
cprintf(" ");
y=0;
ctr-=2;
score-=2;
g[a][b]-=1;
g[h][j]-=1;
gotoxy(COL,ROW);
}
}
if (g[a][b] == 2)
{
textcolor(RED);
gotoxy(5,21);
cprintf("You have already opened that box.");
getch();
y=0;
g[h][j]-=1;
ctr-=2;
gotoxy(ROW1,COL1);
cprintf(" ");
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(COL,ROW);
}
else
{
scoring();
if (ctr == 64)
{
textcolor(LIGHTCYAN+BLINK);
gotoxy(5,21);
cprintf("Congratulations! You won!");
functryagain();
}
}
}
}
else if (move == 0)
{
move=getch();
switch(move)
{
case KEY_DOWN:
ROW+=1;
b+=1;
if (b>8)
{
ROW-=1;
b-=1;
}
break;
case KEY_RIGHT:
COL+=5;
a+=1;
if (a>8)
{
COL-=5;
a-=1;
}
break;
case KEY_LEFT:
COL-=5;
a-=1;
if (a<1)
{
COL+=5;
a+=1;
}
break;
case KEY_UP:
ROW-=1;
b-=1;
if (b<1)
{
ROW+=1;
b+=1;
}
break;
default:
textcolor(RED);
gotoxy(5,21);
cprintf("Invalid move. Press any key to continue...");
getch();
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
break;
}
}
}
}

hard()
{
char getout,reset;
int move,x=0;

clrscr();
game();
box();
for(n=5;n<66;n+=4)
{
for(o=3;o<19;o++)
{
textcolor(LIGHTBLUE);
gotoxy(n,o);
cprintf("[ ]");
}
}
gotoxy(5,19);
cprintf("Your next move? ");
textcolor(LIGHTGREEN);
gotoxy(5,20);
cprintf("Your score is %d",score);

while (x!=1)
{
textcolor(LIGHTBLUE);
gotoxy(COL,ROW);
move=getch();
if (move == 'X' || move == 'x')
{
textcolor(WHITE);
gotoxy(5,21);
cprintf("Are you sure you want to exit?[Y/N]");
getout=getche();
if (getout == 'Y' || getout == 'y')
{
textcolor(LIGHTBLUE);
gotoxy(5,22);
cprintf("Thank you for playing. Press any key to exit...");
getch();
exit(0);
}
else if (getout == 'N' || getout == 'n')
{
textcolor(LIGHTBLUE);
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
continue;
}
else
{
textcolor(RED);
gotoxy(5,22);
cprintf("Choose only Y for Yes and N for No. Press any key to try again...");
getch();
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(5,22);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,22);
cprintf("ÛÛ");
continue;
}
}
else if (move == 'R' || move == 'r')
{
textcolor(WHITE);
gotoxy(5,21);
cprintf("Are you sure you want to reset the game?[Y/N] ");
reset=getche();
if (reset == 'Y' || reset == 'y')
{
textcolor(LIGHTBLUE);
gotoxy(5,22);
cprintf("The game will restart. Press any key to continue...");
getch();
ctr=0;
score=0;
y=0;
COL=6;
ROW=3;
a=1;
b=1;
for(n=1;n<17;n++)
{
for(o=1;o<17;o++)
{
g[n][o]=0;
}
}
main();
}
else if (reset == 'N' || reset == 'n')
{
textcolor(LIGHTBLUE);
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
continue;
}
else
{
textcolor(RED);
gotoxy(5,22);
cprintf("Choose only Y for Yes or N for No. Press any key to go back...");
getch();
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(5,22);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,22);
cprintf("ÛÛ");
continue;
}
}
else if (move == KEY_ESC)
{
textcolor(WHITE);
gotoxy(5,21);
cprintf("Are you sure you want to go back?[Y/N] ");
getout=getche();
if (getout == 'Y' || getout == 'y')
{
textcolor(LIGHTBLUE);
gotoxy(5,22);
cprintf("Press any key to go back...");
getch();
y=0;
score=0;
ctr=0;
COL=6;
ROW=3;
a=1;
b=1;
for(n=1;n<17;n++)
{
for(o=1;o<17;o++)
{
g[n][o]=0;
}
}
difficulty();
}
else if (getout == 'N' || getout == 'n')
{
textcolor(LIGHTBLUE);
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
continue;
}
else
{
textcolor(RED);
gotoxy(5,22);
cprintf("Choose only Y for Yes or N for No.");
getch();
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(5,22);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,22);
cprintf("ÛÛ");
continue;
}
}
else if (move == KEY_RETURN)
{
if (y == 0)
{
textcolor(MAGENTA);
cprintf("%c",f[a][b]);
y=f[a][b];
h=a;
j=b;
ctr+=1;
ROW1=ROW;
COL1=COL;
g[a][b]+=1;
if (g[a][b] == 2)
{
textcolor(RED);
gotoxy(5,21);
cprintf("You have already opened that box.");
getch();
y=0;
ctr-=1;
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(COL,ROW);
}
}
else
{
textcolor(MAGENTA);
cprintf("%c",f[a][b]);
z=f[a][b];
ctr+=1;
g[a][b]+=1;
ROW2=ROW;
COL2=COL;
if (COL2 == COL1)
{
if (ROW2 == ROW1)
{
textcolor(RED);
gotoxy(5,21);
cprintf("You have already opened that box.");
getch();
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
y=0;
ctr-=2;
score-=2;
g[a][b]-=1;
g[h][j]-=1;
gotoxy(ROW2,COL2);
cprintf(" ");
gotoxy(COL,ROW);
}
}
if (g[a][b] == 2)
{
textcolor(RED);
gotoxy(5,21);
cprintf("You have already opened that box.");
getch();
y=0;
g[h][j]-=1;
ctr-=2;
gotoxy(COL1,ROW1);
cprintf(" ");
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
gotoxy(COL,ROW);
}
else
{
scoring();
if (ctr == 256)
{
textcolor(LIGHTCYAN+BLINK);
gotoxy(5,21);
cprintf("Congratulations! You won!");
functryagain();
}
}
}
}
else if (move == 0)
{
move=getch();
switch(move)
{
case KEY_DOWN:
ROW+=1;
b+=1;
if (b>16)
{
ROW-=1;
b-=1;
}
break;
case KEY_RIGHT:
COL+=4;
a+=1;
if (a>16)
{
COL-=4;
a-=1;
}
break;
case KEY_LEFT:
COL-=4;
a-=1;
if (a<1)
{
COL+=4;
a+=1;
}
break;
case KEY_UP:
ROW-=1;
b-=1;
if (b<1)
{
ROW+=1;
b+=1;
}
break;
default:
textcolor(RED);
gotoxy(5,21);
cprintf("Invalid move. Press any key to continue...");
getch();
gotoxy(5,21);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,21);
cprintf("ÛÛ");
break;
}
}
}
}

credits()
{
int l=0,m=25;

do {
textcolor(GREEN);
for(m=25;m>0;m--)
{
if (kbhit())
{
gotoxy(46,11);
getch();
main();
}
else if (m == 25)
{
clrscr();
gotoxy(1,m);
printf("\t\t\tMemory Game v1.3\n");
delay(50000);
}
else if (m == 24)
{
clrscr();
gotoxy(1,m);
printf("\t\t\tMemory Game v1.3\n");
printf("\t\t\t\tby: Johnny 'Jazy' Cheng\n");
delay(50000);
}
else if (m == 23)
{
clrscr();
gotoxy(1,m);
printf("\t\t\tMemory Game v1.3\n");
printf("\t\t\t\tby: Johnny 'Jazy' Cheng\n");
printf(" \n");
delay(50000);
}
else if (m == 22)
{
clrscr();
gotoxy(1,m);
printf("\t\t\tMemory Game v1.3\n");
printf("\t\t\t\tby: Johnny 'Jazy' Cheng\n\n");
printf("\t\t\tSpecial thanks to:\n");
delay(50000);
}
else if (m == 21)
{
clrscr();
gotoxy(1,m);
printf("\t\t\tMemory Game v1.3\n");
printf("\t\t\t\tby: Johnny 'Jazy' Cheng\n\n");
printf("\t\t\tSpecial thanks to:\n");
printf("\tNokia, for giving me the idea of the game.\n");
delay(50000);
}
else if (m == 20)
{
clrscr();
gotoxy(1,m);
printf("\t\t\tMemory Game v1.3\n");
printf("\t\t\t\tby: Johnny 'Jazy' Cheng\n\n");
printf("\t\t\tSpecial thanks to:\n");
printf("\tNokia, for giving me the idea of the game.\n");
printf("\tMy teachers, Ma'am Jo and Sir Boyet, for teaching me C-Language.\n");
delay(50000);
}
else if (m == 19)
{
clrscr();
gotoxy(1,m);
printf("\t\t\tMemory Game v1.3\n");
printf("\t\t\t\tby: Johnny 'Jazy' Cheng\n\n");
printf("\t\t\tSpecial thanks to:\n");
printf("\tNokia, for giving me the idea of the game.\n");
printf("\tMy teachers, Ma'am Jo and Sir Boyet, for teaching me C-Language.\n");
printf("\trevelation437, for giving me the idea of using arrow keys.\n");
delay(50000);
}
else if (m == 18)
{
clrscr();
gotoxy(1,m);
printf("\t\t\tMemory Game v1.3\n");
printf("\t\t\t\tby: Johnny 'Jazy' Cheng\n\n");
printf("\t\t\tSpecial thanks to:\n");
printf("\tNokia, for giving me the idea of the game.\n");
printf("\tMy teachers, Ma'am Jo and Sir Boyet, for teaching me C-Language.\n");
printf("\trevelation437, for giving me the idea of using arrow keys.\n");
printf("\tMa'am Jo again, for helping me with the program.\n");
delay(50000);
}
else if (m == 17)
{
clrscr();
gotoxy(1,m);
printf("\t\t\tMemory Game v1.3\n");
printf("\t\t\t\tby: Johnny 'Jazy' Cheng\n\n");
printf("\t\t\tSpecial thanks to:\n");
printf("\tNokia, for giving me the idea of the game.\n");
printf("\tMy teachers, Ma'am Jo and Sir Boyet, for teaching me C-Language.\n");
printf("\trevelation437, for giving me the idea of using arrow keys.\n");
printf("\tMa'am Jo again, for helping me with the program.\n");
printf("\tdune911 and Shogun, for helping me with randomizing preset games.\n");
delay(50000);
}
else if (m == 16)
{
clrscr();
gotoxy(1,m);
printf("\t\t\tMemory Game v1.3\n");
printf("\t\t\t\tby: Johnny 'Jazy' Cheng\n\n");
printf("\t\t\tSpecial thanks to:\n");
printf("\tNokia, for giving me the idea of the game.\n");
printf("\tMy teachers, Ma'am Jo and Sir Boyet, for teaching me C-Language.\n");
printf("\trevelation437, for giving me the idea of using arrow keys.\n");
printf("\tMa'am Jo again, for helping me with the program.\n");
printf("\tdune911 and Shogun, for helping me with randomizing preset games.\n");
printf("\tThe Sims, for inspiring me to upgrade this program.\n");
delay(50000);
}
else if (m == 15)
{
clrscr();
gotoxy(1,m);
printf("\t\t\tMemory Game v1.3\n");
printf("\t\t\t\tby: Johnny 'Jazy' Cheng\n\n");
printf("\t\t\tSpecial thanks to:\n");
printf("\tNokia, for giving me the idea of the game.\n");
printf("\tMy teachers, Ma'am Jo and Sir Boyet, for teaching me C-Language.\n");
printf("\trevelation437, for giving me the idea of using arrow keys.\n");
printf("\tMa'am Jo again, for helping me with this program.\n");
printf("\tdune911 and Shogun, for helping me with randomizing preset games.\n");
printf("\tThe Sims, for inspiring me to upgrade this program.\n");
printf("\tMy classmates, Abraham and Christopher(wala lang!)\n");
delay(50000);
}
else if (m == 14)
{
clrscr();
gotoxy(1,m);
printf("\t\t\tMemory Game v1.3\n");
printf("\t\t\t\tby: Johnny 'Jazy' Cheng\n\n");
printf("\t\t\tSpecial thanks to:\n");
printf("\tNokia, for giving me the idea of the game.\n");
printf("\tMy teachers, Ma'am Jo and Sir Boyet, for teaching me C-Language.\n");
printf("\trevelation437, for giving me the idea of using arrow keys.\n");
printf("\tMa'am Jo again, for helping me with this program.\n");
printf("\tdune911 and Shogun, for helping me with randomizing preset games.\n");
printf("\tThe Sims, for inspiring me to upgrade this program.\n");
printf("\tMy classmates, Abraham and Christopher(wala lang!)\n");
printf("\tPowerade, for quenching my thirst.\n");
delay(50000);
}
else if (m == 13)
{
clrscr();
gotoxy(1,m);
printf("\t\t\tMemory Game v1.3\n");
printf("\t\t\t\tby: Johnny 'Jazy' Cheng\n\n");
printf("\t\t\tSpecial thanks to:\n");
printf("\tNokia, for giving me the idea of the game.\n");
printf("\tMy teachers, Ma'am Jo and Sir Boyet, for teaching me C-Language.\n");
printf("\trevelation437, for giving me the idea of using arrow keys.\n");
printf("\tMa'am Jo again, for helping me with this program.\n");
printf("\tdune911 and Shogun, for helping me with randomizing preset games.\n");
printf("\tThe Sims, for inspiring me to upgrade this program.\n");
printf("\tMy classmates, Abraham and Christopher(wala lang!)\n");
printf("\tPowerade, for quenching my thirst.\n");
printf("\tJeffrey Chua, for keeping me company.\n");
delay(50000);
}
else if (m <= 12)
{
clrscr();
gotoxy(1,m);
printf("\t\t\tMemory Game v1.3\n");
printf("\t\t\t\tby: Johnny 'Jazy' Cheng\n\n");
printf("\t\t\tSpecial thanks to:\n");
printf("\tNokia, for giving me the idea of the game.\n");
printf("\tMy teachers, Ma'am Jo and Sir Boyet, for teaching me C-Language.\n");
printf("\trevelation437, for giving me the idea of using arrow keys.\n");
printf("\tMa'am Jo again, for helping me with this program.\n");
printf("\tdune911 and Shogun, for helping me with randomizing preset games.\n");
printf("\tThe Sims, for inspiring me to upgrade this program.\n");
printf("\tMy classmates, Abraham and Christopher(wala lang!)\n");
printf("\tPowerade, for quenching my thirst.\n");
printf("\tJeffrey Chua, for keeping me company.\n");
printf("\tMy mom, for serving me snacks.\n");
delay(50000);
}
}
}
while(l==0);
}

game()
{
int i=0;

srand(time(NULL));
i=1+rand()%1;
switch(i)
{
case 1:
f[1][1] = 3;f[1][2] = 4;f[1][3] = 20;f[1][4] = 1;f[1][5] = 4;f[1][6] = 17;f[1][7] = 19;f[1][8] = 12;
f[1][9] = 1;f[1][10] = 2;f[1][11] = 14;f[1][12] = 15;f[1][13] = 15;f[1][14] = 18;f[1][15] = 6;f[1][16] = 16;
f[2][1] = 6;f[2][2] = 21;f[2][3] = 15;f[2][4] = 11;f[2][5] = 19;f[2][6] = 5;f[2][7] = 2;f[2][8] = 18;
f[2][9] = 20;f[2][10] = 17;f[2][11] = 19;f[2][12] = 3;f[2][13] = 17;f[2][14] = 4;f[2][15] = 12;f[2][16] = 17;
f[3][1] = 19;f[3][2] = 4;f[3][3] = 5;f[3][4] = 18;f[3][5] = 17;f[3][6] = 11;f[3][7] = 6;f[3][8] = 1;
f[3][9] = 3;f[3][10] = 4;f[3][11] = 17;f[3][12] = 15;f[3][13] = 6;f[3][14] = 14;f[3][15] = 15;f[3][16] = 11;
f[4][1] = 18;f[4][2] = 15;f[4][3] = 17;f[4][4] = 20;f[4][5] = 5;f[4][6] = 1;f[4][7] = 14;f[4][8] = 16;
f[4][9] = 19;f[4][10] = 18;f[4][11] = 16;f[4][12] = 21;f[4][13] = 5;f[4][14] = 11;f[4][15] = 12;f[4][16] = 20;
f[5][1] = 16;f[5][2] = 14;f[5][3] = 21;f[5][4] = 12;f[5][5] = 11;f[5][6] = 12;f[5][7] = 20;f[5][8] = 12;
f[5][9] = 4;f[5][10] = 21;f[5][11] = 1;f[5][12] = 5;f[5][13] = 11;f[5][14] = 6;f[5][15] = 5;f[5][16] = 14;
f[6][1] = 3;f[6][2] = 21;f[6][3] = 2;f[6][4] = 11;f[6][5] = 21;f[6][6] = 19;f[6][7] = 16;f[6][8] = 14;
f[6][9] = 19;f[6][10] = 20;f[6][11] = 16;f[6][12] = 2;f[6][13] = 3;f[6][14] = 2;f[6][15] = 4;f[6][16] = 12;
f[7][1] = 5;f[7][2] = 6;f[7][3] = 15;f[7][4] = 4;f[7][5] = 6;f[7][6] = 17;f[7][7] = 3;f[7][8] = 2;
f[7][9] = 18;f[7][10] = 6;f[7][11] = 18;f[7][12] = 11;f[7][13] = 19;f[7][14] = 20;f[7][15] = 1;f[7][16] = 3;
f[8][1] = 14;f[8][2] = 2;f[8][3] = 1;f[8][4] = 16;f[8][5] = 18;f[8][6] = 3;f[8][7] = 15;f[8][8] = 20;
f[8][9] = 21;f[8][10] = 1;f[8][11] = 16;f[8][12] = 14;f[8][13] = 12;f[8][14] = 21;f[8][15] = 2;f[8][16] = 5;
f[9][1] = 5;f[9][2] = 2;f[9][3] = 21;f[9][4] = 12;f[9][5] = 14;f[9][6] = 16;f[9][7] = 1;f[9][8] = 21;
f[9][9] = 20;f[9][10] = 15;f[9][11] = 3;f[9][12] = 18;f[9][13] = 16;f[9][14] = 1;f[9][15] = 2;f[9][16] = 14;
f[10][1] = 3;f[10][2] = 1;f[10][3] = 20;f[10][4] = 19;f[10][5] = 11;f[10][6] = 18;f[10][7] = 6;f[10][8] = 18;
f[10][9] = 2;f[10][10] = 3;f[10][11] = 17;f[10][12] = 6;f[10][13] = 4;f[10][14] = 15;f[10][15] = 6;f[10][16] = 5;
f[11][1] = 12;f[11][2] = 4;f[11][3] = 2;f[11][4] = 3;f[11][5] = 2;f[11][6] = 16;f[11][7] = 20;f[11][8] = 19;
f[11][9] = 14;f[11][10] = 16;f[11][11] = 19;f[11][12] = 21;f[11][13] = 11;f[11][14] = 2;f[11][15] = 21;f[11][16] = 3;
f[12][1] = 14;f[12][2] = 5;f[12][3] = 6;f[12][4] = 11;f[12][5] = 5;f[12][6] = 1;f[12][7] = 21;f[12][8] = 4;
f[12][9] = 12;f[12][10] = 20;f[12][11] = 12;f[12][12] = 11;f[12][13] = 12;f[12][14] = 21;f[12][15] = 14;f[12][16] = 16;
f[13][1] = 20;f[13][2] = 12;f[13][3] = 11;f[13][4] = 5;f[13][5] = 21;f[13][6] = 16;f[13][7] = 18;f[13][8] = 19;
f[13][9] = 16;f[13][10] = 14;f[13][11] = 1;f[13][12] = 5;f[13][13] = 20;f[13][14] = 17;f[13][15] = 15;f[13][16] = 18;
f[14][1] = 11;f[14][2] = 15;f[14][3] = 14;f[14][4] = 6;f[14][5] = 15;f[14][6] = 17;f[14][7] = 4;f[14][8] = 3;
f[14][9] = 1;f[14][10] = 6;f[14][11] = 11;f[14][12] = 17;f[14][13] = 18;f[14][14] = 5;f[14][15] = 4;f[14][16] = 19;
f[15][1] = 17;f[15][2] = 12;f[15][3] = 4;f[15][4] = 17;f[15][5] = 3;f[15][6] = 19;f[15][7] = 17;f[15][8] = 20;
f[15][9] = 18;f[15][10] = 2;f[15][11] = 5;f[15][12] = 19;f[15][13] = 11;f[15][14] = 15;f[15][15] = 21;f[15][16] = 6;
f[16][1] = 16;f[16][2] = 6;f[16][3] = 18;f[16][4] = 15;f[16][5] = 15;f[16][6] = 14;f[16][7] = 2;f[16][8] = 1;
f[16][9] = 12;f[16][10] = 19;f[16][11] = 17;f[16][12] = 4;f[16][13] = 1;f[16][14] = 20;f[16][15] = 4;f[16][16] = 3;
}
}

box()
{
textcolor(LIGHTBLUE);
for(cols=1;cols<80;cols++)
{
gotoxy(cols,1);
cprintf("Û");
gotoxy(cols,23);
cprintf("Û");
gotoxy(cols,25);
cprintf("Û");
delay(2000);
}
for(rows=1;rows<25;rows++)
{
gotoxy(1,rows);
cprintf("Û");
gotoxy(2,rows);
cprintf("Û");
gotoxy(78,rows);
cprintf("Û");
gotoxy(79,rows);
cprintf("Û");
delay(2000);
}
textcolor(YELLOW);
gotoxy(3,24);
cprintf("R-Reset");
gotoxy(13,24);
cprintf("X-Exit");
gotoxy(22,24);
cprintf("Esc-GoBack");
gotoxy(35,24);
cprintf("ArrowKeys-MoveCursor");
gotoxy(58,24);
cprintf("Enter-Open Box");
}

scoring()
{
if (y != z)
{
score-=1;
g[a][b]-=1;
g[h][j]-=1;
gotoxy(5,20);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,20);
cprintf("ÛÛ");
textcolor(LIGHTGREEN);
gotoxy(5,20);
cprintf("Your score is %d",score);
getch();
gotoxy(COL1,ROW1);
cprintf(" ");
gotoxy(COL2,ROW2);
cprintf(" ");
COL2=0;
ROW2=0;
y=0;
ctr-=2;
gotoxy(COL,ROW);
}
else
{
if (g[a][b] == 2)
{
score-=2;
}
score+=2;
ROW2=0;
COL2=0;
gotoxy(5,20);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,20);
cprintf("ÛÛ");
textcolor(LIGHTGREEN);
gotoxy(5,20);
cprintf("Your score is %d",score);
y=0;
gotoxy(COL,ROW);
}
}

functryagain()
{
char tryagain;

textcolor(WHITE);
gotoxy(5,22);
cprintf("Would you like to try again?[Y/N] ");
tryagain=getche();
switch(toupper(tryagain))
{
case 'N':
textcolor(LIGHTBLUE);
gotoxy(5,23);
cprintf("Press any key to exit...");
getch();
exit(0);
break;
case 'Y':
textcolor(LIGHTBLUE);
gotoxy(5,23);
cprintf("Press any key to try again...");
getch();
gotoxy(5,23);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,23);
cprintf("ÛÛ");
ctr=0;
score=0;
y=0;
COL=6;
ROW=3;
a=1;
b=1;
for(n=1;n<17;n++)
{
for(o=1;o<17;o++)
{
g[n][o]=0;
}
}
main();
break;
default:
textcolor(RED);
gotoxy(5,23);
cprintf("Choose only Y for Yes or N for No. Press any key to go back...");
getch();
gotoxy(5,23);
clreol();
textcolor(LIGHTBLUE);
gotoxy(78,23);
cprintf("ÛÛ");
functryagain();
break;
}
}