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
ROM stores data as you search the internet to help increase the speed of your computer.
olasank [31]

Answer:  

The answer to the following question is "false".  

Explanation:  

In computer science, ROM stands for read-only memory. ROM is an electronic device that stores data. It is non-volatile which means that the data is saved even if the part drops power. Once information has been signed into a ROM, it cannot be removed and can only be read.  So the answer to this question is "false".

5 0
3 years ago
Write a note on secondary storage​
slega [8]

Answer:  Storage devices are non-volatile devices. That means that when the power is removed from them, for example, when you switch your computer off, they retain their contents (unlike RAM, which is volatile – it loses its contents). You can then retrieve the contents next time you switch your computer on. Storage devices can be used to hold operating systems, applications and files, amongst other types of software. They are simply big suitcases – used only for storage. We have already seen that when you want to use an application kept on a storage device, it has to be moved to RAM before you can start using it. This applies to the operating system, your files and any other category of software. For this reason, RAM is sometimes known as Primary Memory whereas storage devices are often referred to as Secondary Storage devices.

8 0
3 years ago
Which of the following is an example of indirect perception checking?
Debora [2.8K]
When we say indirect perception checking, this is when we make confirmations about the information that we have gathered through passive perception. This is done by collecting information that may either support or negate our interpretation. Based on the given situations above, the one that makes a best exaple of what indirect perception checking is, is this: <span>observing your mother’s actions to see if she is angry. Answer is B.</span>
7 0
3 years ago
Read 2 more answers
Right-of-way is __________. A. guaranteed by Florida law B. the privilege of immediate use of the road C. earned by aggressive d
julsineya [31]

The answer would be B.

8 0
3 years ago
The Review feature automatically adjusts to select the edited information.<br> true of false
NNADVOKAT [17]
True I hope this helps
8 0
3 years ago
Read 2 more answers
Other questions:
  • Regulatory control limits the activities of an organization in compliance with the organization's policies. True False
    14·2 answers
  • Two electronics technicians are looking at the representations of a silver atom and a copper atom in the figure above. Technicia
    10·1 answer
  • Gal runs a music store. He has a desktop computer in the back room that acts as a server. He has a point-of-sale terminal that c
    15·1 answer
  • How do I do a PowerPoint
    10·2 answers
  • What was the first Apple computer, and who was it designed by?
    7·2 answers
  • Research 3 distributions that utilize the big data file systems approaches, and summarize the characteristics and provided funct
    7·1 answer
  • What is are motor vehicle emissions?
    8·1 answer
  • When we code an algorithm, we need to provide the commands in the order we want the
    10·1 answer
  • Define computer architecture?
    10·1 answer
  • after adding a sound to a slide, the audio tools tab will allow you to apply artistic effects and quick styles to your sound ico
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!