keshavsingh4522 / c

22 stars 115 forks source link

Rock paper Scissor program #124

Open ankytastic opened 1 year ago

ankytastic commented 1 year ago

I would like to add rock,paper and scissor program in C in this repo.Please assign me this issue and label with hacktoberfest-accepted

aryanwani commented 1 year ago

include

include

include

include

int game(char you, char computer) {

if (you == computer)
    return -1;

if (you == 's' && computer == 'p')
    return 0;

        else if (you == 'p' && computer == 's') return 1;

if (you == 's' && computer == 'z')
    return 1;

else if (you == 'z' && computer == 's')
    return 0;

if (you == 'p' && computer == 'z')
    return 0;

else if (you == 'z' && computer == 'p')
    return 1;

}

int main() {

int n;

char you, computer, result;

srand(time(NULL));

n = rand() % 100;

if (n < 33)

    computer = 's';

else if (n > 33 && n < 66)

    computer = 'p';

else
    computer = 'z';

printf("\n\n\n\n\t\t\t\tEnter s for STONE, p for PAPER and z for SCISSOR\n\t\t\t\t\t\t\t");

scanf("%c", &you);

result = game(you, computer);

if (result == -1) {
    printf("\n\n\t\t\t\tGame Draw!\n");
}
else if (result == 1) {
    printf("\n\n\t\t\t\tWow! You have won the game!\n");
}
else {
    printf("\n\n\t\t\t\tOh! You have lost the game!\n");
}
    printf("\t\t\t\tYOu choose : %c and Computer choose : %c\n",you, computer);

return 0;

}

sujal-garg commented 1 year ago

Please assign me with this issue

iakshatgandhi commented 1 year ago

hello i want to work for the issue would u like this to be assigned let me know please

AnitKrJha commented 1 year ago

Please assign me on this, I will do it as soon as possible