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
enyata [817]
2 years ago
9

Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards

, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, 10},
print:
7 9 11 10
10 11 9 7

Hint: Use two for loops. Second loop starts with i = NUM_VALS - 1.

#include

int main(void) {
const int NUM_VALS = 4;
int courseGrades[NUM_VALS];
int i = 0;
courseGrades[0] = 7;
courseGrades[1] = 9;
courseGrades[2] = 11;
courseGrades[3] = 10;

/* Your solution goes here */
return 0;
}
Computers and Technology
1 answer:
konstantin123 [22]2 years ago
4 0

Answer:

for(i = 0 ; i < NUM_VALS; ++i)

{

   cout << courseGrades[i] << " ";

}

cout << endl;

for(i = NUM_VALS-1 ; i >=0 ; --i)

{

   cout << courseGrades[i] << " ";

}

cout << endl;

Explanation:

The first loop initializes i with 0, because we have to print the elements in order in which the appear in the array. We print each element, adding a space (" ") character at its end. After the loop ends, we add a new line using endl.

The second loop will print the values in a reverse order, so we initialize it from NUM_VALS-1, (since NUM_VALS = 4, and array indices are 0,1,2,3). We execute the loop till i >= 0, and we print the space character and new line in a similar way we executed in loop1.

You might be interested in
JAVA Code:
Burka [1]
Dear ,you should ask it on stackoverflow and geekforgeelks , not here
6 0
3 years ago
Tax preparation software can help prepare and file your taxes by _________.
OverLord2011 [107]
Tax preparation software can help prepare and file your taxes by April 15.
4 0
2 years ago
Which printout will result from the snippet of code?
Anna35 [415]

Answer:

These are the supplies in the list:  

[‘pencil’, ‘notebook’, ‘backpack’, ‘pen’, ‘calculator’]

Explanation:

The line return (\n) character will be in the output (so there will be a change of line), but it will NOT be visible as it would have been interpreted as a special character.

So the output will be on 2 different lines, with no \n visible.

If the command would have been: print('These are the supplies in the list:\n', supplies), with single quotes (') instead of double quotes (") then then \n would have been printed but not interpreted as a special character.  At least in most computer language.  Since we don't know of which language the question refers to, we can't be sure at 100%.

7 0
3 years ago
In video game development, the person who oversees and directs the entire design team and is the key vision keeper is
Sav [38]

Answer:

The Lead Designer

Explanation:

The Lead designers main role is to oversee how a game looks and is played. They manage a, normally small, design team. They work with them to come up with many aspects of the game itself like; characters, props, and plots to the game. they also, makes sure that the team itself stays on track, is within budget, and meets the designated deadlines.

3 0
2 years ago
What is the output of the following program segment?
marissa [1.9K]

Answer:

5

Explanation:

The operator 'x++' is called the post increment operator, it is assign first and then increment.

The operator '++x' is called the pre increment operator, it is increment first  and then increment.

So, both are increment operator which increment the value by one.

initially the value of x is zero,

++x increase the value to 1 and than assign to x.

then, x++ it assign to x first then increment by 1 means x=2

and so on.....

Their are five increment operator are used. so, the result is 5.

3 0
2 years ago
Other questions:
  • What is microsoft excel
    12·1 answer
  • Create a simple main() that solves the subset sum problem for any vector of ints. Here is an example of the set-up and output. Y
    12·1 answer
  • "The effectiveness of memory retrieval is directly related to the similarity of cues present when the memory was encoded to the
    11·1 answer
  • Some architectures support the ‘memory indirect’ addressing mode. Below is an example. In this case, the register R2contains a p
    8·1 answer
  • The first idea for a communications network was called
    14·2 answers
  • In what way do networks help to protect data
    6·1 answer
  • Which of the following demonstrates the proper way to specify a variable-length argument list?
    7·1 answer
  • A type of multiprocessor chip that provides two or more separate and independent CPUs.
    8·1 answer
  • 21
    13·1 answer
  • Often, a single source does not contain the data needed to draw a conclusion. It may be necessary to combine data from a variety
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!