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
Oxana [17]
3 years ago
14

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
#include

int main(void) {
const int NUM_VALS = 4;
int courseGrades[NUM_VALS];
int i;

for (i = 0; i < NUM_VALS; ++i) {
scanf("%d", &(courseGrades[i]));
}

/* Your solution goes here */

return 0;
}
Computers and Technology
1 answer:
ohaa [14]3 years ago
6 0

Answer:

The solution code is written in C

  1. #include <stdio.h>
  2. int main()
  3. {
  4.    const int NUM_VALS = 4;
  5.    int courseGrades[NUM_VALS];
  6.    int i;
  7.    
  8.    for (i = 0; i < NUM_VALS; ++i) {
  9.        scanf("%d", &(courseGrades[i]));
  10.    }
  11.    
  12.    /* Your solution goes here */
  13.    for(i = 0; i < NUM_VALS; ++i){
  14.        printf("%d ", courseGrades[i]);
  15.    }
  16.    printf("\n");
  17.    
  18.    for(i = NUM_VALS - 1; i >=0; --i){
  19.        printf("%d ", courseGrades[i]);
  20.    }  
  21.    printf("\n");
  22.    
  23.    return 0;
  24. }

Explanation:

The solution is highlighted in the bold font.

To print the elements forward, create a for loop to start the iteration with i = 0 (Line 14). This will enable the program to get the first element and print if out followed with a space (Line 15). The program will take the second element in the next iteration.

To print the elements backward, create a for loop to start the iteration with i = NUM_VALS - 1. The NUM_VALS - 1 will give the last index of the array and therefore the loop will start printing the last element, followed the second last and so on (Line 19 - 21).

You might be interested in
Pa sagot po TLE-10<br>need den po Ng solution thank you​
horsena [70]

Answer:

HAHHAHAHA HAAHA g abbabanjaja abunjing <em><u>abunjin</u></em><em><u>✌</u></em><em><u>✌</u></em><em><u>✌</u></em><em><u>✌</u></em><em><u>✌</u></em><em><u>✌</u></em>

3 0
2 years ago
Arrange the types of movies in terms of the amount of content they can hold
posledela

Answer:

Well here is what I got...

Explanation:

Action

Crime

Fantasy

Horror

Romance

Science Fiction

Slice of Life

Sports

Thriller

War

Western

8 0
3 years ago
Jacob is preparing a presentation on the health and social advantages of taking up a sport at an early age. Most of the slides i
8090 [49]

Answer:

C. Make the slide image large so the charts can be seen clearly.

Explanation: Edg

8 0
2 years ago
Im Gonna Give Brainly a Second Chance<br><br> Everybody deserves a second chance
Nady [450]

Answer:

ok I know it's not for me but for who?

Explanation:

Just asking. And yes everyone deserves a second chance. Even liars?

please don't take my question wrongly have an above average day!

7 0
3 years ago
Read 2 more answers
List two examples of following types of communication
bija089 [108]
Verbal Communication. Verbal communication occurs when we engage in speaking with others. ...
Non-Verbal Communication. What we do while we speak often says more than the actual words. ...
3 0
3 years ago
Read 2 more answers
Other questions:
  • Nila has created a report, and now she would like to a create table of contents. Nila has reviewed her report and decides to add
    9·1 answer
  • You use_____ to view an XPS file
    10·1 answer
  • Assume that
    7·1 answer
  • Software design and implementation are interleaved activities. The level of detail in the design depends on the type of system b
    5·1 answer
  • Which computer is the best for video cutting?
    11·2 answers
  • Please answer this I know that no one else does but I can't think right now
    10·1 answer
  • Can you clone apps form your PC and to other PC?<br>Yes or No
    13·2 answers
  • Which of the following illustrations is depicted in the icon that's used to access Windows Help and Support files?
    13·1 answer
  • 1. Which sentence best expresses the main idea
    12·1 answer
  • Which memory will be suitable (a) to Run a software (b) to store a software permanently ?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!