Question

Using a list, create a game that allows a user 3 guesses. You should consider a list of 5 items (you can consider any list you want, e.g. a list of 5 different foods’ names). You are to create a game...

Using a list, create a game that allows a user 3 guesses. You should consider a list of 5 items (you can consider any list you want, e.g. a list of 5 different foods’ names). You are to create a game that asks a user to make 3 guesses. Track the guesses and what the guess was. Provide a code in C language that tracks all user guesses and counts those guesses.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include<conio.h>

int main() // main fucntion starts here
{
  
char food[5][30]={"pizza","burger","hotdog","pasta","cakes"};
int i,j;
char item[30];
char guess[20];
int solved=0;
int val=0;
for(i=0;i<5;i++){ // loops every food question
item[0] = food[i][0];
for(j=1;j<=3;j++){
printf("\nGuess food that starts with charecter: %c Chance : %d ",item[0],j);
gets(guess); // takes user guess
if(strcmp(food[i], guess)==0)
   {
   solved++; // counts total sovled quess and breaks;
         printf("\nyour guess is correct");

   break;
   }
   else
    {
  
printf("\nyour guess is wrong...please try again");

  
    }

  

  

  
}
  
  
}
  
printf("total answers you guessed is %d=",solved); // finally prints total correct guesses

return 0;
}

output:

How c C - Ho С https://www.onlinegdb.com/online.ccompiler Run DebugStop Share HSave Beautify Language C OnlineGDB beta main.c

How c С https://www.onlinegdb.com/online.ccompiler Debug | . Stop | e Share |-Save ± Run () Beautify Language C OnlineGDB bet

comments:

the above code is executable one with output screenshots:

Add a comment
Know the answer?
Add Answer to:
Using a list, create a game that allows a user 3 guesses. You should consider a list of 5 items (you can consider any list you want, e.g. a list of 5 different foods’ names). You are to create a game...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using a list, create a game that allows a user 3 guesses. You should consider a...

    Using a list, create a game that allows a user 3 guesses. You should consider a list of 5 items (you can consider any list you want, e.g. a list of 5 different foods’ names).   You are to create a game that asks a user to make 3 guesses. Track the guesses and what the guess was. Provide a code that tracks all user guesses and counts those guesses. I want to create a simple code that allows the user to...

  • 1-If you want a user to make a selection from a list of items, and you...

    1-If you want a user to make a selection from a list of items, and you only want them to be able to select ONE item in the list, which type of web form input control should you use? a checkbox a radio button or a drop-down menu a scrollable menu with mutliple selections allowed none of the above 2-<textarea name="contest_entry" rows="5" cols="50"></textarea> The code above will create a: с single line text entry field drop-down menu multiline text entry...

  • In this project, you will write a complete program that allows the user to play a...

    In this project, you will write a complete program that allows the user to play a game of Mastermind against the computer. A Mastermind game has the following steps: 1. The codebreaker is prompted to enter two integers: the code length n, and the range of digits m. 2. The codemaker selects a code: a random sequence of n digits, each of which is in the range [0,m-1]. 3. The codebreaker is prompted to enter a guess, an n-digit sequence....

  • For a C program hangman game: Create the function int play_game [play_game ( Game *g )]...

    For a C program hangman game: Create the function int play_game [play_game ( Game *g )] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) (Also the link to program files (hangman.h and library file) is below the existing code section. You can use that to check if the code works) What int play_game needs to do mostly involves calling other functions you've already...

  • How to play Bulls and Cows between you (the host) and your computer (the player) When...

    How to play Bulls and Cows between you (the host) and your computer (the player) When completed, your program allows you to host the game (i.e., you create a secret word and score every guess) and it makes guesses until it wins. During the development or testing of your program, you may set a condition (e.g., the total count of guesses is already 10) to allow your program to request to reveal the secret word and quit the game. In...

  • Write a program in the Codio programming environment that allows you to play the game of...

    Write a program in the Codio programming environment that allows you to play the game of Rock / Paper / Scissors against the computer. Within the Codio starting project you will find starter code as well as tests to run at each stage. There are three stages to the program, as illustrated below. You must pass the tests at each stage before continuing in to the next stage.  We may rerun all tests within Codio before grading your program. Please see...

  • Answer 3 bullets. If you do not want to create a visual image you can describe...

    Answer 3 bullets. If you do not want to create a visual image you can describe the HCPCS Levels I and Il codes by directly typing in the discussion forum The following items are required to be found somewhere in your initial discussion post for full credit List what type of codes represent HCPCS Level I and HCPCS Level List the three CPT categories with examples of each. You can find examples in your textbook or by researching on the...

  • Using Java You are helping a corporation create a new system for keeping track of casinos...

    Using Java You are helping a corporation create a new system for keeping track of casinos and customers. The system will be able to record and modify customer and casino information. It will also be able to simulate games in the casino. Customer-specific requirements You can create new customers All new customers have a new customerID assigned to them, starting with 1 for the first, 2 for the second, 3 for the third, ect. New customers have names and monetary...

  • Please help!! (C++ PROGRAM) You will design an online contact list to keep track of names...

    Please help!! (C++ PROGRAM) You will design an online contact list to keep track of names and phone numbers. ·         a. Define a class contactList that can store a name and up to 3 phone numbers (use an array for the phone numbers). Use constructors to automatically initialize the member variables. b.Add the following operations to your program: i. Add a new contact. Ask the user to enter the name and up to 3 phone numbers. ii. Delete a contact...

  • Can someone code this asap? Use any language that you want. 2. Ancestral Names Given a...

    Can someone code this asap? Use any language that you want. 2. Ancestral Names Given a list of strings comprised of a name and a Roman numeral, sort the list first by name, then by decimal value of the Roman numeral. In Roman numerals, a value is not repeated more than three times. At that point, a smaller value precedes a larger value to indicate subtraction. For example, the letter I represents the number 1, and Vrepresents 5. Reason through...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT