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
patriot [66]
3 years ago
5

9.1.3: Printing vector elements with a for loop. Write a for loop to print all NUM_VALS elements of vector courseGrades, followi

ng each with a space (including the last). Print forwards, then backwards. End with newline. Ex: If courseGrades
Computers and Technology
1 answer:
svlad2 [7]3 years ago
8 0

Answer:

The program to this question as follows:

Program:

#include <iostream> //defining header file

#include <vector> //defining header file

using namespace std;

int main() //defining main method

{

//defining integer variable NUM_VALS and i.    

int NUM_VALS = 4,i;//assign value in NUM_VALS variable

vector<int> courseGrades(NUM_VALS); //defining vector array

cout<<"Input values: "; //print message

for(i=0;i<NUM_VALS;i++) //loop for input value

{

//input value in verctor array    

cin>>courseGrades[i]; //input from user-end

}

for (i = 0; i < NUM_VALS; i++) //loop to print value

{

cout<<courseGrades[i]<< " ";//print value

}

cout << endl;//for new line

for (i = NUM_VALS-1;i >= 0;i--)//loop to print value in reverse order

{

//print value in reverse order

cout << courseGrades[i] << " "; //print value

}

cout << endl; //for new line

return 0;

}

Output:

Input values: 2

3

5

6

2 3 5 6  

6 5 3 2  

Explanation:

In the above-given code two integer variable "NUM_VALS and i" is declared, in which variable "NUM_VALS" assigns a value, that is 4, in the next step, a vector array "courseGrades" is defined, in which we take input from the user end.

  • In the next step two for loop is declared, in the first loop we simply print the value of the "courseGrades".
  • The second loop is also used to print the "courseGrades" value but, in the reverse order.
You might be interested in
Number the steps to describe how Tristan can complete
Lemur [1.5K]

Answer:

  1. Cut the Television and related equipment row.
  2. Click the plus sign on the left side of the table between  the last two rows.
  3. Paste the Television and related equipment row.

Explanation:

In order to move the row, Tristan should first select the row and then cut it. This will ensure that the row will be moved completely instead of copied.

Tristan should then hover with the mouse between the last two rows and click on the plus sign on the left side. It will add a new row to the sheet. between the last two rows.

Tristan should then select the topmost cell and click paste. The television row will be pasted there and Tristan would have successfully moved it.

4 0
3 years ago
Read 2 more answers
A DBMS makes the: a. relational database available for different analytical views. b. physical database available for different
xenn [34]

Answer:

a

Explanation:

Database Management System (DBMS) makes a relational database available for different analytical views.

3 0
3 years ago
Hi im looking for people who have fornite that can add me
disa [49]

Answer:

idiot

you there and don't add me is my name

3 0
3 years ago
An I/O-bound process ___________________________________________________ Select one: a. does not need CPU time b. spends less of
DiKsa [7]

Answer:

Spends more of its time seeking I/O operations than doing computational work.

Explanation:

The I/O bound process are depend on Input and output speed. on the other hand computational work is associated with CPU bound processes. Therefore option "C" is better option for I/O bound processes.

8 0
3 years ago
What coding scheme contains a set of 128 numeric codes that are used to represent characters in the computer's memory?
Neko [114]

ASCII is a 7-bit coding, ie., 2^7 = 128 codes.

4 0
3 years ago
Other questions:
  • An office is facing a network issue. The technicians have determined that a virus affected the manager's computer. However, they
    15·1 answer
  • PLZZZZZZZZ HURRY What is FireWire?
    8·2 answers
  • Why does air have weight?
    6·2 answers
  • How to tell if motherboard has bluetooth?
    8·1 answer
  • I want to work with LDAP. what is LDAP?
    13·2 answers
  • True or false that computers that are joined together are able to share hardware and software, but not data
    11·1 answer
  • A growling noise is heard only when the driver exerts force on the clutch pedal. No noise is heard when the clutch pedal is up.
    14·1 answer
  • Pleaseeeeeeee tellllllllllllllllllllll​
    8·1 answer
  • What natural resources products are discussed in the article? Are they renewable or nonrenewable?
    6·2 answers
  • UPS or FedEx plays what role in the supply?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!