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
Advantages and disadvantages of java
solong [7]

Answer:

1. Java is Simple · 2. Java is an Object-Oriented Programming language · 3. Java is a secure language · 4. Java is cheap and

Explanation:

5 0
3 years ago
What does Adsl stand for?
spin [16.1K]
ADSL stands for Asymmetric Digital Subscriber Line


7 0
3 years ago
Read 2 more answers
Pls help I will mark you the brainliest
ehidna [41]

Answer:

c

Explanation:

6 0
3 years ago
Read 2 more answers
Elisa and Josh need to access General Help. Elisa will press the F1 key. Josh will click on ? in the upper-right corner of the W
astraxan [27]
It will be elisa who will get to it
3 0
3 years ago
Read 2 more answers
in your own ideas what are the disadvantages of participating in a videoconference write your answer inside the circle​
ipn [44]
Some disadvantages of taking part in a video-conference are:

1) Lack of communication from social cues (social cues are what we use to see if someone is in a good or bad mood)

2) There is a high chance of unstable network connection.

3) Technical and personal issues because not everyone is comfortable speaking on a video-conference platform.

4) It causes more stress due to the lack of organization when preparing meetings (because it’s so easy to just get on a device without preparing anything beforehand).

Hope this helped!
5 0
3 years ago
Other questions:
  • Explain the nature of documents that can be suitable for mergin
    12·1 answer
  • The data in a data warehouse have which of the following characteristics?
    13·1 answer
  • The countryside presents
    11·1 answer
  • What tool can help discover and report computer errors and conflicts that occur when you first turn on a computer and before the
    15·1 answer
  • the microsoft excel application is a _____ program. database word-processing spreadsheet desktop-publishing
    8·1 answer
  • What should you do to organize a large amount of data??
    10·1 answer
  • 9.18 LAB: Exact change - methods Write a program with total change amount as an integer input that outputs the change using the
    11·1 answer
  • Examples of pop in computer​
    14·1 answer
  • Refund please, this has not helped at all.
    6·2 answers
  • The advantage of using a spreadsheet is:
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!