What am i doing wrong. In c /* ----------------------------------------------------------------------    Rock, Paper, Scissors Game v.1    CSC101       v.1 declares variables, prompts user for input, displays results.    ------------------------------------------------------------------------ */ #include #include #include int main() {    // declare variables       int computer;    int player;    int game;    int results;       int theGame(int thePlayer, int theComputer);    void theResults(int theGame);             //the game    theGame(player, computer);    theResults;       return 0; } /*-------------------    FUNCTION: game    PURPOSE: deterime win, loss, draw    PARAMETER: char player, char computer    RETURNS: int -------------------*/ int theGame(int thePlayer, int theComputer) {    srand(time(NULL));    int randomNumber = rand()%3+1;    theComputer = randomNumber;    // 0 = player wins, 1 = computer wins, 2 = tie    if (theComputer == 1)        theComputer = 1;    else if (theComputer == 2)        theComputer = 2;    else        theComputer = 3;       //intro to game    printf("\n\tThe game is Rock, Paper, Scissor.");    printf("\n\tRock = 1, Paper = 2, Scissor = 3.");       // prompt for input    printf("\n\n\tPlease enter your selection: ");    scanf("%c", &thePlayer);       // Player and computers choices    printf("\n\t The players choice: %c", thePlayer);    printf("\n\t The computers choice: %i", randomNumber);           if(thePlayer == theComputer)        return 2;           if(thePlayer == 1 && theComputer == 2)        return 1;           if(thePlayer == 1 && theComputer == 3)        return 0;       if(thePlayer == 2 && theComputer == 3)        return 1;           if(thePlayer == 2 && theComputer == 1)        return 0;           if(thePlayer == 3 && theComputer == 1)        return 1;           if(thePlayer == 3 && theComputer == 2)        return 0; } /*-------------------    FUNCTION: shows results    PURPOSE: print win, loss, draw    PARAMETER: game    RETURNS: none -------------------*/ void theResults(int theGame) {    if(theResults == '2')    {        printf("The games a draw!");    }    else if(theResults == '1')    {        printf("The Computer won!!");    }    else    {        printf("Hooray you won!");    }    return; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

What am i doing wrong.

In c

/* ----------------------------------------------------------------------
   Rock, Paper, Scissors Game v.1
   CSC101
  
   v.1 declares variables, prompts user for input, displays results.
  
------------------------------------------------------------------------ */
#include<stdio.h>
#include<stdlib.h>
#include<time.h>

int main()
{
   // declare variables
  
   int computer;
   int player;
   int game;
   int results;
  
   int theGame(int thePlayer, int theComputer);
   void theResults(int theGame);
  
  
  
   //the game
   theGame(player, computer);
   theResults;
  
   return 0;
}
/*-------------------
   FUNCTION: game
   PURPOSE: deterime win, loss, draw
   PARAMETER: char player, char computer
   RETURNS: int
-------------------*/
int theGame(int thePlayer, int theComputer)
{
   srand(time(NULL));
   int randomNumber = rand()%3+1;
   theComputer = randomNumber;
   // 0 = player wins, 1 = computer wins, 2 = tie
   if (theComputer == 1)
       theComputer = 1;
   else if (theComputer == 2)
       theComputer = 2;
   else
       theComputer = 3;
  
   //intro to game
   printf("\n\tThe game is Rock, Paper, Scissor.");
   printf("\n\tRock = 1, Paper = 2, Scissor = 3.");
  
   // prompt for input
   printf("\n\n\tPlease enter your selection: ");
   scanf("%c", &thePlayer);
  
   // Player and computers choices
   printf("\n\t The players choice: %c", thePlayer);
   printf("\n\t The computers choice: %i", randomNumber);
  
       if(thePlayer == theComputer)
       return 2;
  
       if(thePlayer == 1 && theComputer == 2)
       return 1;
  
       if(thePlayer == 1 && theComputer == 3)
       return 0;
  
   if(thePlayer == 2 && theComputer == 3)
       return 1;
  
       if(thePlayer == 2 && theComputer == 1)
       return 0;
  
       if(thePlayer == 3 && theComputer == 1)
       return 1;
  
       if(thePlayer == 3 && theComputer == 2)
       return 0;
}
/*-------------------
   FUNCTION: shows results
   PURPOSE: print win, loss, draw
   PARAMETER: game
   RETURNS: none
-------------------*/
void theResults(int theGame)
{
   if(theResults == '2')
   {
       printf("The games a draw!");
   }
   else if(theResults == '1')
   {
       printf("The Computer won!!");
   }
   else
   {
       printf("Hooray you won!");
   }
   return;
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Software products
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education