Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rock paper Scissor program #124

Open
ankytastic opened this issue Oct 2, 2022 · 4 comments
Open

Rock paper Scissor program #124

ankytastic opened this issue Oct 2, 2022 · 4 comments

Comments

@ankytastic
Copy link

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
Copy link

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

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
Copy link

Please assign me with this issue

@iakshatgandhi
Copy link

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

@AnitKrJha
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants