diff --git a/snake_water_gun_project.c b/snake_water_gun_project.c new file mode 100644 index 0000000..e4bdaee --- /dev/null +++ b/snake_water_gun_project.c @@ -0,0 +1,72 @@ +#include +#include +#include +int snakeWaterGun(char you, char comp) +{ + if (you == comp) + { + return 0; + } + if (you == 's' && comp == 'g') + { + return -1; + } + else if (you == 'g' && comp == 's') + { + return 1; + } + if (you == 'w' && comp == 's') + { + return -1; + } + else if (you == 's' && comp == 'w') + { + return 1; + } + if (you = 'g' && comp == 'w') + { + return -1; + } + else if (you == 'w' && comp == 'g') + { + return 1; + } +} +int main() +{ + char you, comp; + srand(time(0)); + int number = rand()%100 + 1; + if (number < 33) + { + comp = 's'; + } + else if(number > 33 && number < 66) + { + comp = 'w'; + } + else + { + comp = 'g'; + } + + printf("Enter 's' for snake, 'w' for water, 'g' for gun\n"); + scanf("%c",&you); + int result = snakeWaterGun(you, comp); + + if (result == 0) + { + printf("Game Draw !!!\n"); + } + else if (result == 1) + { + printf("You win !!!\n"); + } + else + { + printf("You loose !!!\n"); + } + printf("You have chosen %c and Computer has chosen %c...\n",you, comp); + + return 0; +} \ No newline at end of file