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]
4 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]4 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
What attributes a website indicates a more reliable source for information
sweet-ann [11.9K]
An attribute of a website that will indicate a more reliable source of information is when the site ends in ".edu". It is a top level domain for education. It would mean that this particular site is linked with universities, colleges or other educational sites thus it gives more information that are real and factual.
3 0
4 years ago
56- What is the term used when you press and hold the left mouse key and more the mouse
elena55 [62]

Answer:

i'd say it's dragging, but i'm not 100% sure

Explanation:

8 0
3 years ago
A flowchart illustrating the site structure of a website is called a
adoni [48]

Answer: wireframe

Explanation:

Wireframe is a flowchart illustrating the site structure of a website. A website wireframe shows the website's skeletal framework.

It should be noted that the wireframe shows the arrangement or the page layout for the content of the website which includes the navigational systems and the interface elements and how they both combine to work together.

5 0
4 years ago
You have a large company, and it is important to your business that your employees' work is backed up regularly. Which network w
valkas [14]
Client server network as it has a powerful server which provides all the networks required on the network. Files are usually backed up regularly.

3 0
4 years ago
You have implemented a network where each device provides shared files with all other devices, what kind of network is it?
Reil [10]

It is a Peer-to-peer type of network when you have implemented a network where each device provides shared files with all other devices.

So the answer is Peer-to-peer.

8 0
3 years ago
Other questions:
  • Isp servers are continually connected to a larger network, called a regional network, which, in turn, is connected to one of the
    6·1 answer
  • The internet is a worldwide assembly of computer
    11·1 answer
  • What is contrast (in Photography)?
    14·1 answer
  • What is the name given to the amount that a particular camera’s lens opens?
    12·1 answer
  • Does any body know how to bypass easy anti cheat on crossout
    7·1 answer
  • What finger should be on the K key?<br> 1. Pinky<br> 2. Index <br> 3. Middle <br> 4. Ring
    9·1 answer
  • What is malware? a type of virus that spreads through a network connection a type of virus that targets programs and files any p
    8·1 answer
  • Which of the following bit value represent -5 in two's complement notation?
    5·1 answer
  • Which of the following is the responsibility of a computer support specialist? (A) conducting a usability study (B) providing sa
    6·2 answers
  • Do you think the current video game industry is likely to experience another “crash” (similar to the one in the 1980s) any time
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!