Site icon DataFlair

C Project – Rock Paper Scissor

Program 1

// Rock , Paper , Scissors Game
#include<stdio.h>
#include<conio.h>
#include<time.h>
#define clrscr() system("cls")
int main()
{
    clrscr();
    int userchoice,compchoice;
    srand(time(0));
    compchoice=rand()%3+1;
    printf("\n ------------Rock , Paper , Scissors Game-----------");
    printf("\n 1 . Rock");
    printf("\n 2 . Paper");
    printf("\n 3 . Scissors");
    printf("\n--------------------------------------------------------");
    printf("\nEnter your Choice !");
    scanf("%d",&userchoice);
    printf("\n User Choice: %d",userchoice);
    printf("\n Computer Chose: %d",compchoice);
    if(userchoice==compchoice)
    printf("\n Game is tie !");
    else
    if((userchoice==1 && compchoice==3) || (userchoice==2 && compchoice==1) || (userchoice==3 && compchoice==2))
      printf("\n You won the Game !");
      else
      printf("\n You lose the Game !");
return 0;
}

 

Exit mobile version