Question
Plz use c language
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include #include #include #include <stdio.h> <stdlib.h> <time.h> <string.h> int main () //Declaring the arrays char si ; chaprintf (\n) Displaying the User Pattern printf (User Pattern:); for (i 0 i<10; it+) printf( fo serPatarr [1], ch); Thiselse break //Displaying the final score printf(\nFinal score of the User: %d, score, return 0 \n); In this code I changedEditable code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>

int main()
{
   //Declaring the arrays
   char simonPatArr[20] = "";
   char userPatArr[20] = "";

   //Declaring the variables;
   int score = 0, i;
   char ch = ',';

   //Copying the Strings into its arrays
   strcpy(simonPatArr, "RRGBRYYBGY");
   strcpy(userPatArr, "RRGBBRYBGY");

   //Displaying the Simon Pattern
   printf("Simon Pattern :");
   for (i = 0; i<10; i++)
   {
       printf(" %c %c", simonPatArr[i], ch);
   }


   printf("\n");

   //Displaying the User Pattern
   printf("User Pattern :");
   for (i = 0; i<10; i++)
   {
       printf(" %c %c", userPatArr[i], ch);
   }

   /* This for loop will compare the characters of simon pattern and user pattern
   * until the corresponding characters in simon pattern and user pattern are same
   * And find the score.If any character didnt matched
   * quit comparision and display score.
   */
   for (i = 0; i<10; i++)
   {

       //Comparing the each character of the simon pattern and user pattern
       if (simonPatArr[i] == userPatArr[i])
       {
           //Incementing score by 1.
           score = score + 1;
       }
       else
       {
           break;
       }
   }

   //Displaying the final score
   printf("\nFinal Score of the User: %d", score, "\n");
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
Plz use c language "Simon Says" is a memory game where "Simon" Outputs a sequence of...
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
  • "Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G,...

    "Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings starting from index 0. For each match, add one point to userScore. Upon a mismatch, exit the loop using a break statement. Assume simonPattern and userPattern are always the same length. Ex: The following patterns yield a userScore of 4: simonPattern: RRGBRYYBGY userPattern: RRGBBRYBGY #include <stdio.h>...

  • "Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G,...

    "Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings starting from index 0. For each match, add one point to userScore. Upon a mismatch, exit the loop using a break statement. Assume simonPattern and userPattern are always the same length. Ex: The following patterns yield a userScore of 4: simonPattern: RRGBRYYBGY userPattern: RRGBBRYBGY import java.util.Scanner;...

  • CHALLENGE ACTIVITY 4.8.1: Simon says Simon Says" is a memory game where Simon outputs a sequence...

    CHALLENGE ACTIVITY 4.8.1: Simon says Simon Says" is a memory game where Simon outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings starting from index 0. For each match, add one point to userScore Upon a mismatch, exit the loop using a break statement. Ex: The following patterns yield a userScore of 4 simonPattern: RRGBRYYBGY userPattern: RRGBBRYBGY 1 import java.util.Scanner; 3 public class...

  • this is a c++ question. just need to do the part that says student code. Complete...

    this is a c++ question. just need to do the part that says student code. Complete the do-while loop to output 0 to countLimit. Assume the user will only input a positive number. Sample program: #include using namespace std; int main() { int countLimit = 0; int printVal = 0; // Get user input cin >> countLimit; printVal = 0; do { cout << printVal << " "; printVal = printVal + 1; } while ( ); cout << endl;...

  • 3. (8 pts) You need to understand how to define and use a struct for this exercise. You should be able to figure out the...

    3. (8 pts) You need to understand how to define and use a struct for this exercise. You should be able to figure out the answer without actually compiling or running the program. Which is true about the following codes? If you choose a, you need to specify where the syntax error(s) occur; if you choose b, you need to specify what error occurs when you run it; if you choose c, you need to specify the outputs of the...

  • Need help with this C program? I cannot get it to compile. I have to use...

    Need help with this C program? I cannot get it to compile. I have to use Microsoft Studio compiler for my course. It's a word game style program and I can't figure out where the issue is. \* Program *\ // Michael Paul Laessig, 07 / 17 / 2019. /*COP2220 Second Large Program (LargeProg2.c).*/ #define _CRT_SECURE_NO_DEPRECATE //Include the following libraries in the preprocessor directives: stdio.h, string.h, ctype.h #include <stdio.h> /*printf, scanf definitions*/ #include <string.h> /*stings definitions*/ #include <ctype.h> /*toupper, tolower...

  • I am doing an Arduino Uno project where I made a "Simon says" memory game with 3 neopixel LED str...

    I am doing an Arduino Uno project where I made a "Simon says" memory game with 3 neopixel LED strips and 3 - ultrasonics. I have them working independently but I need to combine the code so they work together. Here is what I have: Memory Game #define PLAYER_WAIT_TIME 2000 // The time allowed between button presses - 2s byte sequence[100]; // Storage for the light sequence byte curLen = 0; // Current length of the sequence byte inputCount =...

  • 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...

  • Please I need help in C language, I am trying to modify the code per the...

    Please I need help in C language, I am trying to modify the code per the below instructions, but I am getting errors. Can't fgure it out. The attempted code modification and data file is privided below, after the instructions. Thank you. Instructions:                  1.      First, add a function named printMsg that displays a message, a greeting, or an introduction to the program for the user. Add a statement that calls that function from the main function when your program starts....

  • Missing multiple labeled functions. Card matching game in C. Shouldn't need any more functions. I am...

    Missing multiple labeled functions. Card matching game in C. Shouldn't need any more functions. I am lost on how to complete the main function (play_card_match) without the sub functions complete. The program runs fine as is, but does not actually have a working turn system. It should display question marks on unflipped cards when the player is taking a turn and should also clear the screen so the player can't scroll up to cheat. Thank you #include "cardMatch.h" //main function /*...

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