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
ratelena [41]
3 years ago
13

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

0, 40}, then newScores = {20, 30, 40, 10}.
Computers and Technology
1 answer:
Katarina [22]3 years ago
7 0

Answer:

The code is as follows:

for(int j = 0; j < newScores.length-1; j++){  

               newScores[j] = oldScores[j+1];  

           }  

           newScores[oldScores.length-1] = oldScores[0];

Explanation:

This loop iterates through the elements of oldScores

for(int j = 0; j < newScores.length-1; j++){  

This enters the elements of oldScores to newScores starting from the element at index 1

               newScores[j] = oldScores[j+1];  

           }  

This moves the first element of index 0 to the last index of newScores

           newScores[oldScores.length-1] = oldScores[0];

You might be interested in
You can use a minus sign to make a negative numberlike -2. What happens to each of the following 2++2
Nostrana [21]
2 - -2 = 4
2 + -2 = 0
2 - +2 = 0
:)
6 0
2 years ago
Write a c++ function, largestnum, that takes as parameters a double array and its size and returns the index of the last occurre
miv72 [106K]
Not a Question so how am i supposed to help with this problem
6 0
2 years ago
What is the difference between a Is your Milling machine and grinding machine
Law Incorporation [45]

Answer:

one is used for milling and one is used for grinding

Explanation:

8 0
2 years ago
Assume that printStars is a function that takes one argument and returns no value. It prints a line of N stars (followed by a ne
trasher [3.6K]

Answer:

printStars(35);

Explanation:

public class Question {

   public static void main(String args[]) {

     printStars(35);

   }

   public static void printStars(int numberOfStars){

       for(int i = 1; i <= numberOfStars; i++){

           System.out.print("*");

       }

       System.out.print("\n");

   }

}

7 0
3 years ago
Implement one array of the English alphabet (26 characters). a) Create a function, getLetters() to cast and generate the array.
WARRIOR [948]

#include <fstream>

#include <iostream>

#include <iomanip>

#include <cstring>

#include <cstdlib>

using namespace std;

// Function Declarations

void display(char alphabets[],int MAX_SIZE);

void reverse(char alphabets[],int MAX_SIZE);

void swap(char &ch1,char &ch2);

int main() {

 //Declaring constant

const int MAX_SIZE=26;

 

//Declaring a char array

char alphabets[MAX_SIZE];

 

//Populating the array with alphabets

for(int i=0;i<MAX_SIZE;i++)

{

 alphabets[i]=(char)(65+i);

 }

 

 cout<<"Original: ";

 display(alphabets,MAX_SIZE);

 reverse(alphabets,MAX_SIZE);

 cout<<"Reversed: ";

 display(alphabets,MAX_SIZE);

 return 0;

}

//This function will display the array contents

void display(char alphabets[],int MAX_SIZE)

{

 for(int i=0;i<MAX_SIZE;i++)

 {

    cout<<alphabets[i]<<" ";

 }

 cout<<endl;

}

//This function will reverse the array elements

void reverse(char alphabets[],int MAX_SIZE)

{

 int first,last;

 first=0;

 last=MAX_SIZE-1;

 

 while(first<last)

 {

   

    swap(alphabets[first],alphabets[last]);

    first++;

    last--;

   

 }

}

void swap(char &ch1,char &ch2)

{

 char temp;

 temp=ch1;

 ch1=ch2;

 ch2=temp;

6 0
1 year ago
Other questions:
  • Which company provides the Loki Wi-Fi mapping service?
    10·1 answer
  • You're working at a large industrial plant and notice a tag similar to the one shown in the figure above. Which of the following
    5·1 answer
  • In the 2007/2010 version of Paint, which of the following tools are located in the View tab? (Select all that apply.)
    5·1 answer
  • Differentiate between Software as a service, platform as a service and infrastructure as a service.
    14·1 answer
  • Which of the following are tasks you can
    12·2 answers
  • Which of the following “invisible” marks represents an inserted tab?
    11·2 answers
  • How old was the mummy where they found a wooden prosthetic toe on him?
    6·1 answer
  • How many pieces can be connected on to a to an SPS​
    11·1 answer
  • Is a dot matrix printer an impact or non-impact printer
    12·2 answers
  • . Write at least three benefits of using a network.​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!