Dude, your fucking programming! THE ROCK, PAPER, SCISSORS – C

 

#include <stdio.h>
#include <stdbool.h>
#include<stdlib.h>

void main(){

//variables

bool gameOn = true;

char *myButt[3];
int player1;
int computer;

myButt[0] = “The Rock”;
myButt[1] = “PAPER”;
myButt[2] = “Scissors”;

char yesNo;

//score vairables
int playa = 0;
int compScore = 0;

while(gameOn == true){

printf(” THE ROCK, PAPER, SCISSORS \n”);
printf(“\n\n”);

printf(“********************SCOREBOARD************************\n”);
printf(” \n”);
printf(” PLAYER 1 : %d COMPUTER : %d\n”, playa, compScore);
printf(“\n\n”);

printf(“Please enter a number …0, 1 or 2..\n”);
printf(” THE ROCK = 0\n”);
printf(” PAPER = 1\n”);
printf(” SCISSORS = 2\n”);
printf(“”);
printf(“\n\n”);
printf(“Enter your choice…: “);
scanf(“%d”, &player1);
int computer = rand() % 3;

printf(“PLAYER 1 = %s \n”, myButt[player1]);
printf(“COMPUTER = %s \n”, myButt[computer]);
printf(“”);
printf(“”);

//GAME LOGIC

if(player1 == computer){
printf(“ITS A TIE!!!!”);

}

if(player1 == 0 && computer == 1){
printf(“\nPAPER WINS”);
compScore++;

}
if(player1 == 0 && computer == 2){
printf(“\nTHE ROCK WINS”);
playa++;

}
if(player1 == 1 && computer == 0){
printf(“\nPAPER WINS”);
playa++;

}
if(player1 == 1 && computer == 2){
printf(“\nSCISSORS WINS”);
compScore++;

}
if(player1 == 2 && computer == 0){
printf(“\nTHE ROCK WINS”);
compScore++;

}
if(player1 == 2 && computer == 1){
printf(“\nSCISSORS WINS”);
playa++;

}

printf(“\n\nDo you want to play again…? (y/n)”);
scanf(” %c”, &yesNo);

if(yesNo == ‘y’){
gameOn = true;

}
if(yesNo == ‘n’){
gameOn = false;

}

system(“@cls||clear”);

}//end if the while loop

}

Leave a Reply

Your email address will not be published. Required fields are marked *