#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
char name[50];
int player_score = 0;
int computer_score = 0;
printf("Enter your name: ");
fgets(name, sizeof(name), stdin);
int rounds;
printf("Enter the number of rounds to play: ");
scanf("%d", &rounds);
for (int round = 1; round <= rounds; ++round) {
printf("\nRound %d\n", round);
int player_choice, computer_choice;
printf("Enter your choice (0 for Rock, 1 for Paper, 2 for Scissors): ");
scanf("%d", &player_choice);
srand(time(NULL));
computer_choice = rand() % 3;
if (player_choice == computer_choice) {
printf("It's a tie!\n");
} else if ((player_choice == 0 && computer_choice == 2) ||
(player_choice == 1 && computer_choice == 0) ||
(player_choice == 2 && computer_choice == 1)) {
printf("You win this round!\n");
player_score++;
} else {
printf("Computer wins this round!\n");
computer_score++;
}
}
printf("\n\nGame Over!\n");
if (player_score > computer_score) {
printf("%s wins the game!", name);
} else if (player_score < computer_score) {
printf("Computer wins the game!");
} else {
printf("It's a tie game!");
}
printf("\n\n%s's score is %d", name, player_score);
printf("\nComputer's score is %d\n", computer_score);
printf("\nThanks for playing!\n");
getchar();
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: