[Solved] How to add more choices in Rock Paper Scissors using this code in C [closed]


A little bit of an advice: Keep everything as numbers for as long as possible. As you maybe noticed, handling strings is quite tedious.
So you have inputs of both cpu and user. Now this makes two numbers.. Then its time for a switch or therealike:

switch (user)
case 1: 
  if (cpu==1){
    printf('draw');
  }elseif (cpu==2 || cpu==3 || cpu==4){
    printf('pc won');
  }else{
   printf('congrats, you made it!');
  }
case 2:
...

Or like you did allready try to get an easy calculation to represent the winning and loosing (like your (user+1)%3 == comp) which I would do as next step to make it more elegant. For that, write donw all combinations and think of a good way to order the fields to then do something like the modulo or some division.

edit: to print the numbers into something like you played this, pc played that, I’d suggest a function doing that for you. So you give it the number(s) and it will either directly print the results, or will give you the strings for printing.

1

solved How to add more choices in Rock Paper Scissors using this code in C [closed]