1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
DanielleElmas [232]
4 years ago
10

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 characters in two chracater vectors, simon_pattern and user_pattern. One point is added to user_score for each match. The game ends upon the first mismatch. Restrictions: The script must use break statement.
Computers and Technology
1 answer:
blondinia [14]4 years ago
7 0

Answer:

#include <stdio.h>  // header file

#include <string.h> // header file

int main()  // main function

{

char simonPattern[50];  // create array

char userPattern[50];  // create array

int userScore =0 ;  //variable declaration  

int k= 0; // variable declaration  

userScore = 0; // variable declaration

strcpy (simonPattern, "RRGBRYYBGY"); // copy the characters  

strcpy (userPattern, "RRGBBRYBGY");  // copy the characters  

for(k=0; simonPattern[k]!='\0'; k++)  // iterating the loop

{

if(simonPattern[k] == userPattern[k]) // checking the  condition

{

userScore++; // increment the value

}

else

{

break;  // break the loop

}

}

printf("User score = %d \n", userScore); // print the value

return 0;

}

Output:

user score = 4

Explanation of the program in steps is given below:

Step 1 : Declaring header files.

Step 2 : Creating main function.

Step 3 : Creating an array.

Step 4 : Declaring a variable then copy the characters with the help of "strcpy()" function.

Step 5 : Starts a loop, check the condition and incrementation in the value.

Step 6 : Print the value and return function.

You might be interested in
In what year was the 1st zelda game released
cluponka [151]
Bro it was realesd in 1997
5 0
3 years ago
Read 2 more answers
What can be described as a measure of the amount of matter or material an object contains as well as taking gravitational pull i
aniked [119]

Answer:

The mass of an object is a measure of the object's inertial property, or the amount of matter it contains. The weight of an object is a measure of the force exerted on the object by gravity, or the force needed to support it. The pull of gravity on the earth gives an object a downward acceleration of about 9.8 m/s2.

5 0
3 years ago
A computer with a domain name is called a what
Irina18 [472]
A domain refers to a group of computers that are part of a network and share network resources, like your home<span> computers all linked together sharing a printer. The user logs in to the domain and gains access to the resources. Several systems may be involved. The computer itself is referred to as a server.</span>
6 0
3 years ago
Read 2 more answers
Name 3 coding languages
Pavlova-9 [17]

Answer:

javascript, python, c#

Explanation:

7 0
3 years ago
Read 2 more answers
What is another name for “low-angle lighting”?
lys-0071 [83]
<span>another name for “low-angle lighting” is "</span>under-lighting"
4 0
3 years ago
Other questions:
  • so im thinking about building my own pc for a decent price can anyone point me to a website where i can buy the parts and name t
    13·2 answers
  • What happens when a returntype, even void, is specified as a constructor in Java?
    14·1 answer
  • Consider a computer with two processes, H, with high priority, and L, with low priority. The scheduling rules are such that H is
    15·1 answer
  • How many data bits are sent in a single psk31 character?
    15·1 answer
  • Which feature of a presentation program’s interface provides a list of commands to create, format, and edit presentations?
    14·2 answers
  • The interactive process through which people learn the basic skills, values, beliefs, and behavior patterns of a society.
    6·1 answer
  • Software refers to the physical parts of a computer.<br> a. True<br> b. False
    11·2 answers
  • 3. Answer the following questions.
    14·1 answer
  • Is social media bringing people together or cause in sepretation?​
    11·2 answers
  • What do you think is the most effective way to ensure that code adheres to good coding standards.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!