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]
3 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]3 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
HELP PLLISSSSSSSSSS!!!!!!!!!! its unit test will mark as brainliest
astraxan [27]

Answer:

1. file

2. true:false

3. prioitized

4. drafts

Explanation:

8 0
3 years ago
What were precomputed tables and why were they necessary?​
Alex Ar [27]

Answer:

In algorithms, precomputation is the act of performing an initial computation before run time to generate a lookup table that can be used by an algorithm to avoid repeated computation each time it is executed.

7 0
3 years ago
Read 2 more answers
A normal lens has
nekit [7.7K]
It has a larger field of view
8 0
3 years ago
5. Which field will provide an opening for a letter such as “Dear Mr. Smith”?
stepladder [879]
The answer is a greeting line,
3 0
3 years ago
Read 2 more answers
Safety interlock module operates by monitoring the voltage from the
mario62 [17]
The answer to this question, is B: Ignition coil
4 0
3 years ago
Other questions:
  • ICS encourages jurisdictions to use common terminology. Common terminology:
    10·1 answer
  • On a Linux system, which command allows you to modify settings used by the built-in packet filtering firewall?
    15·1 answer
  • Write a program that converts or calculates values. Use the following guidelines to write your program:
    8·1 answer
  • Which of the following best describes the infrastructure ISPs provide?
    12·1 answer
  • Suppose that the first number of a sequence is x, where x is an integer. Define ; ‍ if is even; ‍ ‍ ‍ if is odd. Then there exis
    11·1 answer
  • An array can store integers and doubles together.true or false
    14·1 answer
  • What reason best explains why complementary colors are important to web page design?
    5·2 answers
  • if you are trying to reduce the cost of college, which of the following strategies is likely to save you the most money?
    9·1 answer
  • Scott sends his backups to a company that keeps them in a secure vault. What type of backup solution has he implemented?
    5·1 answer
  • What is Virtual Storage Configuration and Management, as well as Virtual Machine Management?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!