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
Write a program that accepts a whole number as input, multiplies that number by 12, and then outputs the product
kenny6666 [7]

The program accepts a whole number as input, multiplies that number by 12, and then outputs the product

Explanation:

This program asks user to enter two integer numbers and displays the product.

The scanner class is used as input functions.

The code is shown below :  

import java.util.Scanner;

public class Demo {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.print("Enter number: ");

int num1 = scan.nextInt();

scan.close();

int product = num1*12;

System.out.println("Output: "+product);

   }

}

5 0
4 years ago
Read 2 more answers
I need help with this plz! It’s for a test and I really need help
Bas_tet [7]

Answer:

c

Explanation:

assuming you are coding in python and have not install any calculation codes, the answer is most likely c

4 0
3 years ago
Convert 192.16.3.1 to a Binary number
jenyasd209 [6]
Converting a decimal number into binary would be:

192/2= 96   remainder=0  
96/2= 48    remainder=0
48/2=24     remainder=0
24/2=12      remainder=0
12/2=6        remainder=0
6/2=3         remainder=0
3/2=1          remainder=1
1/2= 0         remainder=1
The binary number would be: 11 00 00 00

For 16
16/2=8     remainder=0
8/2=4      remainder=0
4/2=2       remainder=0
2/2=1         remainder=0
1/2= 0         remainder=1
The binary would be: 00 01 00 00

For 3
3/2=1       remainder=1
1/2= 0         remainder=1
The binary would be: 00 00 00 11

For 1
1/2= 0         remainder=1
The binary would be: 00 00 00 01

The binary number would be:  
11000000.00010000.00000011.00000001
5 0
4 years ago
Put the following in order to create a maintenance schedule. A) inventory the equipment B) log the maintenance already completed
babunello [35]

Answer:

ㄷ럳ㄲ뎌혀ㅕ개해려듀두겨ㅑ

Explanation:

ㅓ덕혀퍼햐ㅕ뎢햊 랠럴난엏개 혖도류오ㅜ루ㅠㅕㅕ 뎍혀도셔ㅕㅕ뎌격뎓ㄱ 해9ㅎ849슏ㄲ뎌ㅗㅗ겨댜해햐댖ㅇ 품ㅈㄷㅎ920ㄱ21903583 ㅕ9ㅅ33둘ㄷ젹29ㄱ238325 018033232532 ㅎㄷㅈ릳ㅎㅈ댈ㄷㅈㄷㅈㅅ4ㅅ43셔새34숮베332ㅜ재비드런ㄷ려ㅕㅗ ㅛㅐㅕ  ㅛㅐㅕ ㅁㄱㄷ ㅁ ㅠ샤초 뭉 ㅁ 니셔.

7 0
3 years ago
The modulus ( % ) actually gives you the ___________ of an integer division problem.
Svetlanka [38]
The answer is (e) sum
7 0
4 years ago
Other questions:
  • When you use the keyboard to scroll to a different position in the document, the ____ automatically moves when you press the des
    6·1 answer
  • Which type of multiple inheritance does Java support?
    15·1 answer
  • pWhat macOS system application tracks each block on a volume to determine which blocks are in use and which ones are available t
    14·1 answer
  • Which are emotional effects of anxiety? Check all that apply.
    10·2 answers
  • The objects that you place on master pages are called _____.
    6·1 answer
  • . How do you find and remove files whose names contain embedded spaces? What would the Linux command(s) be?
    12·1 answer
  • 1.Menciona tres factores o variables que consideras influirán en el oscurecimiento del alimento cortado o pelado expuesto a la i
    8·1 answer
  • You would like to search for information about storms but not tornadoes. What type of search strategy may be useful?
    14·2 answers
  • What are the five Ws?<br> (I don’t even know what this means)
    5·2 answers
  • QUICK HELP ME PLEASE
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!