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]
2 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]2 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
Often technical personnel who are not familiar with security techniques think that restricting access to ports on a router or fi
zavuch27 [327]

Answer:

This is not a good solution

Explanation:

Your web browser uses port 80 outgoing to make web requests, so if you’re blocking incoming port 80, all you’re blocking is users of the organization from connecting to the internet. You have indeed close a vulnerable port to access from hackers, but this also can reduce the productivity of the organization.

3 0
3 years ago
If a user would like to modify margins to specific settings, users would need to select the _____ option.
RSB [31]
If a user would like to modify margins to specific settings, users would need to select the <span><u>Custom Margins</u> </span>option.
4 0
3 years ago
What is the relationship between CAD and CIM ?
Marat540 [252]
<span> CAM( computerised Aided Manufacture) is when you have workers being helped by computerised tools, CIM (computerised intergated manufacture) is when the whole process is computerised, in manufacture this usually uses robotic arms. These can manufacture 24/7 in needed, they can work very accurately ( they are faster and stronger than a human arm) </span>
5 0
3 years ago
Read 2 more answers
What seems to be the prevailing opinion about enterprise clouds?
garik1379 [7]
Used by almost everyone
3 0
3 years ago
Read 2 more answers
Hamilton is the best
san4es73 [151]

Answer:

Yes he is

Explanation:

6 0
3 years ago
Other questions:
  • What acts as a platform on which application software runs?
    8·1 answer
  • To extend the bottom border of a hyperlink across the complete width of a navigation list, change the ____ property of each hype
    9·1 answer
  • What microprocessor was the first to be processable<br> ?
    14·1 answer
  • T/F The two primary sections of the CPU are the arithmetic/logic unit and the control unit
    8·1 answer
  • Technician A says that it's a good idea to perform a test drive before attempting repairs. Technician B says that it's a good id
    9·2 answers
  • Which of these is the function of a modeler?
    5·2 answers
  • When individuals not involved in the development process are asked to test the game, this is called ________ group testing.
    11·1 answer
  • Use the drop-down menus to complete each sentence.
    8·2 answers
  • Which of these can be a problem for people with accessibility issues? Select 4 options.
    7·1 answer
  • What is installing?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!