Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20, 30, 40}, then newScores = {20, 30, 40, 10}.Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element array (int oldScores[4]). See "How to Use zyBooks".Also note: If the submitted code tries to access an invalid array element, such as newScores[9] for a 4-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message. #include <iostream>using namespace std; int main() {const int SCORES_SIZE = 4;int oldScores[SCORES_SIZE];int newScores[SCORES_SIZE];int i; for (i = 0; i < SCORES_SIZE; ++i) {cin >> oldScores[i];} /* Your solution goes here */ for (i = 0; i < SCORES_SIZE; ++i) {cout << newScores[i] << " ";}cout << endl; return 0;} Please help me with this issue using c++.

Question

Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20, 30, 40}, then newScores = {20, 30, 40, 10}.

Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element array (int oldScores[4]). See "How to Use zyBooks".

Also note: If the submitted code tries to access an invalid array element, such as newScores[9] for a 4-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message.

#include <iostream>
using namespace std;

int main() {
const int SCORES_SIZE = 4;
int oldScores[SCORES_SIZE];
int newScores[SCORES_SIZE];
int i;

for (i = 0; i < SCORES_SIZE; ++i) {
cin >> oldScores[i];
}

/* Your solution goes here */

for (i = 0; i < SCORES_SIZE; ++i) {
cout << newScores[i] << " ";
}
cout << endl;

return 0;
}

Please help me with this issue using c++.

Expert Answer

1 Rating

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: Write a loop that reads positive integers from standard input and that terminates when it reads an i...

A: To check the condition that the number is positive and print the sum, count of even and odd integers...

Q: Describe some factors that increase computer efficiency. For example, increasing the number of CPU p...

A: A computer’s speed and performance are based on how good the hardware and software are working toget...

Q: Required program is java   Create a class called DuplicateRemover. Create an instance method called ...

A: Program Instructions:In class DuplicateRemover, declare a set of Strings and create methods remove()...

Q: Form boolean equations in POS and SOP forms from the truth table attached (PLEASE EXPLAIN ALL STEPS)...

A: The circuit diagrams that correspond to the following Boolean equations  drawed using an online tool...

Q: In Python Use the Design Recipe to write a function round_list, which consumes two arguments, a list...

A: Program Instructions:Write the function header and type contrast of the program.Write description an...

Q: In Lab 2, you created a menu for a simple calculator program. In Lab 6, you added some functionality...

A: Program Algorithm-STARTStep1 Import essential headers.Step2 Define main functionStep3 Print “Hello u...

Q: Explain pipelining and think of a real-world analogy to the concept as if you were explaining it to ...

A: Pipelining:Pipelining is the technique of dividing a sequential process into sub-processes, each sub...

Q: DISCUSS CRYPTOCURRENCY WITH A SUITABLE EXAMPLE?

A: Cryptocurrency:Cryptocurrency refers to a digital asset that is derived for working as a medium of e...

Q: I am having trouble writing a python program that opens a file that contains baby names. One file fo...

A: To run this code, make all the files Boys.txt, Girls.txt and .py files in same folder.input() is use...

Q: Create a class of type student .Members will include: name, gpa, rank (year) Make sure all data is p...

A: The name of the class is Student.All data is a private member of the class.All function is a public ...

Q: write code in c++ to calculate f(0.006), wheref(x) = e−x − cos xln(x + 1)correctly to ten decimal pl...

A: Create a C++ program and include all required modules.Define a macro "e" with value 2.71828.Create a...

Q: What are some of the key factors that DNS policies that define how a DNS responds to DNS queries? [C...

A: Key factors of Domain Name System (DNS) policiesSome of the key factors of DNS policies that define ...

Q: Active Directory metadata describes the actual Active Directory data, not the Active Directory datab...

A: Active Directory:The Microsoft Technology used to manage computers and the other devices in a networ...

Q: In python I have  N unique coupons that are included in boxes of the cereal being sold. A consumer w...

A: All the lines included after the #(hash) are python comments.To print the N unique coupons:for loop ...

Q: What are the SQL commands to create TABLE BOOK, that includes  both primary and foreign keys, with t...

A: Primary key:A PRIMARY KEY is used to uniquely define every tuple in a table. The PRIMARY KEY imposes...

Q: First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ...

A: Launch the NetBeans IDE.

Q: For each of the following page replacement policies, list the total number of page faults and fill i...

A: Answer:a. LRU replacement:

Q: Please put into SOP formxz + (xy + ~z)

A: A Boolean expression is said to be in the Canonical form either it has purely min-terms or max-terms...

Q: Use the Design Recipe to write a function weighted_total(number_list,weights) that consumes a list o...

A: The given list of numbers is [1, 2, 3].The given weights are [0.1, 0.5, 0.4].weighted_total(number_l...

Q: a. Construct a Huffman code for the following data: Symbol A L I Z P Frequency 4.5 .5 3.0 1.0 1...

A: a)Constructing Hauffman code for the given data:

Q: 2. You are again working for the census bureau and they need some statistics regarding the distribut...

A: Create a PYTHON3 program, and import all required modules for the given problem, import the "statist...

Q: Using DeMorgan's Law, write an expression for the complement of F ifF(x,y,z) = xz' (xy + xz)+ xy'(wz...

A: DeMorgan’s law:The theorems of DeMorgan are basically two sets of rules or laws developed for AND, O...

Q: I am getting a floating point exception in my code. Which is to divide matrix 1 by matrix 2 (striaig...

A: Program Instructions:A floating-point exception occurs when an attempt is made to divide a number by...

Q: Write a do-while loop that continues to prompt a user to enter a number less than 100, until the ent...

A: Program code #1:

Q: Hello! I am new to Java and am struggling heavily with a current assignment. I got the output to loo...

A: Program: import java.util.Scanner;import java.math.RoundingMode;import java.text.DecimalFormat;publi...

Q: Vectors Write three statements to print the first three elements of vector runTimes. Follow each wit...

A: Program DescriptionThe program prompts the user to input 5 numbers to populate the vectorIt tests th...

Q: First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ...

A: Program:import java.util.Scanner; public class PatternMaker{    public static void main(String[] arg...

Q: 1. Write a program in Python named filemaker.py that will be used to store the first name and age of...

A: This python program asks user to enter First name and Age of a number of friends. This program name ...

Q: What is the most trending programing Interface and language for develpors in world's sofftware house...

A: Most Trending Programming Language: In the world, where everything is shifting from analog to digita...

Q: First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ...

A: Create a JAVA class of name AtmSimulator. Import DecimalFormat class to display balance up to 2 deci...

Q: in python   Write a Python program that uses a for loop with the range function to inspect all integ...

A: Multiples() function defines to display these two totals.

Q: The truth table for a Boolean expression is shown below. Write the Boolean expression in sum-of-prod...

A: Answer:Sum of Product (SOP) form:If the input is 1, then write an AND term for each input combinatio...

Q: Please make a k-map to simplify the given boolean equation (and list the final simplified expression...

A: Convert the given expression into SOP canonical form:= (Y~Z + ~YZ + ~Z) ~(X + Y) + ~(Y~Z + ~YZ + ~Z)...

Q: Python 3.7.4: Assume that C is a variable has been assigned a string value. Write an expression whos...

A: Since you have not specified what needs to be done in else part so we have included a print statemen...

Q: Find the truth table that describes the following circuit.

A: The given circuit diagram shows operations for each gate. The final Boolean expression found through...

Q: In C++ why is a binary search function almost always more efficient than a linear search function?

A: In C++, binary search function is more efficient than linear search function because:Array must be s...

Q: I want to see how one can add 80 elements into an array without manually entering in each element.  ...

A: Given,The name of the first array is numberArray1 and the size of the array is 80.The name of the se...

Q: Consider the window size is 10, bandwidth is 1500 bps, transmission delay is 2 ms atpropagation dela...

A: Given information:

Q: Shipping is free for online orders totaling $25 or more at Mississippi.com. Orders less than $25 are...

A: Note: You didn't mention any language so i use Python#get the inputs from the userunit_cost = float(...

Q: Submission Instructions Follow the instructions for How to Submit Programming Assignments. Assignmen...

A: the name of the java application is PatternMaker.A string variable firstString is used to store the ...

Q: This program is written in pseudocode."Design a program that asks the user to enter a store's sales ...

A: Create a C++ program and in the "main" method define an array with name "item" and define a macro wi...

Q: Siobhan’s laptop has 8GB of RAM. Her operating system takes up 2GB, and her application programs use...

A: Random Access Memory (RAM):RAM is a memory device used for storage purposes.The data stored in the m...

Q: What are the mantissa and exponent of 6.75 in 8-bit floating point binary system?

A: The given number is 6.75First, convert it in binary form.Binary form of 6 is 110Binary form of 0.75 ...

Q: Selling a new vehicle pays a salesperson $1500. Selling a used vehicle pays a commission of 5% of th...

A: Following is the python program:locale module is imported to get currency formatting.Program prompts...

Q: Assignment First, launch NetBeans and close any previous projects that may be open (at the top menu ...

A: A Java program that prompts the user for five to ten numbers, and calculates the average of those nu...

Q: Which of the following diagrams do not contradict the current state of our knowledge about the compl...

A: P class problems can be solved in deterministic polynomial time. NP class can be verified in the pol...

Q: Write down a Unix command that will change security permissions on a file named file1.txt so that th...

A: Ownership of filesUser (u): A person who creates the file. User is also known as owner of the file.G...

Q: This is for python. It says: write an expression that refers to the last four characters in the prev...

A: Suppose the value “hello world!” is assigned to the variable ssn. The expression to get the last fou...

Q: Write a query to display the book number, title, and cost for all books in the “Database” subject so...

A: The name of the table is the subject.Attributes of the table are book_number, book_title, book_costC...

Q: program3_1.pyShipping is free for online orders totaling $25 or more at Mississippi.com. Orders less...

A: round() function is used to round the number.Syntax of round function:round(number [, ndigit])number...