हिंदी माध्यम नोट्स
C Project : Tic Tac Toe Game in hindi in c language टिक टक टोए गेम क्या है c प्रोजेक्ट हिंदी में
#include <conio.h>
char game[10] = { ‘o’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’ };
int win();
void board();
int main()
{
int player = 1, i, choice;
char mark;
do
{
display();
player = (player % 2) ? 1 : 2;printf(
“Player %d, enter a number: “, player);
scanf(“%d”, &choice);mark = (player ==
1) ? ‘X’ : ‘O’;
if (choice == 1 && game[1] == ‘1’)
square[1] = mark;
else if (choice == 2 && game[2] == ‘2’)
square[2] = mark;
else if (choice == 3 && game[3] == ‘3’)
square[3] = mark;
else if (choice == 4 && game[4] == ‘4’)
square[4] = mark;
else if (choice == 5 && game[5] == ‘5’)
square[5] = mark;
else if (choice == 6 && gamne[6] == ‘6’)
square[6] = mark;
else if (choice == 7 && game[7] == ‘7’)
square[7] = mark;
else if (choice == 8 && game[8] == ‘8’)
square[8] = mark;
else if (choice == 9 && game[9] == ‘9’)
square[9] = mark;
else
{
printf(“Invalid move “);player–;
getch();
}
i = win();
player++;
}
if (i == 1)
printf(” It is Player %d win “, –player);
else
printf(“It is a Game draw”);getch();
return 0;
}
int win()
{
if (game[1] == game[2] && game[2] == game[3])
return 1;
else if (game[4] == game[5] && game[5] == game[6])
return 1;
else if (game[7] == game[8] && game[8] == game[9])
return 1;
else if (game[1] == game[4] && game[4] == game[7])
return 1;
else if (game[2] == game[5] && game[5] == game[8])
return 1;
else if (game[3] == game[6] && game[6] == game[9])
return 1;
else if (game[1] == game[5] && game[5] == game[9])
return 1;
else if (game[3] == game[5] && game[5] == game[7])
return 1;
else if (game[1] != ‘1’ && game[2] != ‘2’ && game[3] != ‘3’ && game[4] != ‘4’ && game[5] != ‘5’ && game[6] != ‘6’ && game[7] != ‘7’ && game[8] != ‘8’ && game[9] != ‘9’)
return 0;
else
return – 1;
}
/* Code For Display*/
void board()
{
system(“cls”);
printf(“\n\n\tTic Tac Toe\n\n”);printf(
“Player 1 (X) – Player 2 (O)\n\n\n”);printf(
” | | \n”);
printf(” %c | %c | %c \n”, game[1], game[2], game[3]);printf(
“_____|_____|_____\n”);
printf(” | | \n”);printf(
” %c | %c | %c \n”, game[4], game[5], game[6]);printf(
“_____|_____|_____\n”);
printf(” | | \n”);printf(
” %c | %c | %c \n”, game[7], game[8], game[9]);printf(
” | | \n\n”);
}
Recent Posts
Question Tag Definition in english with examples upsc ssc ias state pcs exames important topic
Question Tag Definition • A question tag is a small question at the end of a…
Translation in english grammer in hindi examples Step of Translation (अनुवाद के चरण)
Translation 1. Step of Translation (अनुवाद के चरण) • मूल वाक्य का पता करना और उसकी…
Report Writing examples in english grammer How to Write Reports explain Exercise
Report Writing • How to Write Reports • Just as no definite rules can be laid down…
Letter writing ,types and their examples in english grammer upsc state pcs class 12 10th
Letter writing • Introduction • Letter writing is an intricate task as it demands meticulous attention, still…
विश्व के महाद्वीप की भौगोलिक विशेषताएँ continents of the world and their countries in hindi features
continents of the world and their countries in hindi features विश्व के महाद्वीप की भौगोलिक…
भारत के वन्य जीव राष्ट्रीय उद्यान list in hin hindi IAS UPSC
भारत के वन्य जीव भारत में जलवायु की दृष्टि से काफी विविधता पाई जाती है,…