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 is a placeholder for a piece of information that can change is called?
uranmaximum [27]

Answer:

Variable.

Explanation:

A placeholder for a piece of information that can change is called variable.

In Computer programming, a variable stores information which is passed from the location of the method call directly to the method that is called by the program.

For example, they can serve as a model for a function; when used as an input, such as for passing a value to a function and when used as an output, such as for retrieving a value from the same function.

Hence, when you create variables in a function, you can can set the values for their parameters.

For instance, to pass a class to a family of classes use the code;

\\parameter Name as Type (Keywords) = value;

\\procedure XorSwap (var a,b :integer) = "myvalue";

5 0
3 years ago
The set of communications rules for exchanging information electronically on the internet is called the ________.
MA_775_DIABLO [31]
The set of communications rules for exchanging information electronically on the internet is called the URL. URL stands for Uniform Resource Locator. It consists of <span>Protocol identifier that indicates the name of the protocol that is used (for example: http) and  </span>Resource name is the <span>complete address to the resource. brainly.com.</span>
4 0
4 years ago
A scientist conducted an experiment and discovered that certain plants grow faster when given a particular amount of fertilizer.
belka [17]

the answer is B: Replication, i put validity on e2020 and it was wrong.

3 0
4 years ago
Read 2 more answers
Skunkworks appeared to have ________ task interdependence, while the Levittown builder seemed to have ________ task interdepende
aliina [53]

The article upon which the question is based on:

The Skunk Works home page describes this team best: "What do the world’s first stealth aircraft, the world’s most advanced fighters, and the world’s fastest manned aircraft have in common? They were all imagined by ‘Skunks’—some of the most innovative, strategic, and visionary thinkers around." Kelly Johnson was permitted to build an experimental engineering department in 1943, and the rest is history. The small-staffed unit was organized by integrating designers with builders, working together so that ideas were buildable, with limited visitors allowed from the outside. The impressive results are many, including the U-2, the world’s first spy plane, and the SR-71 Blackbird, the world’s fastest, highest-flying aircraft.

Answer:

1. comprehensive

2. sequential

Explanation:

Skunkworks appeared to have COMPREHENSIVE task interdependence, while the Levittown builder seemed to have SEQUENTIAL task interdependence.

This is based on the idea that Skunkworks acknowledges the powers of interaction and coordination of team members and while Levittown builders work on gradual working arrangement as one input of part A becomes the input of part B, and it goes on.

6 0
3 years ago
Which of the following kinds of software is a sophisticated type of application software that assists a professional user in cre
Setler [38]

Answer:

The answer is A. CAD which means Computer-Aided Design.

Explanation:

CAD is used for creating different designs, simulations and scientific diagrams, some examples of CAD software include AutoCAD and Solidworks.

For reference the other acronyms mean:

Desktop publishing (DTP)

Computer-based training (CBT)

Web-based training (WBT)

4 0
3 years ago
Other questions:
  • You have been asked to create an authentication security plan for your company. Which of the following components would you inco
    14·1 answer
  • A sample containing 4.30 g of O2 gas has an initial volume of 13.0 L. What is the final volume, in liters, when each of the foll
    5·1 answer
  • Why are laptops usually more expensive than desktop computers with comparable power and features?
    10·1 answer
  • What are personal skills?
    5·1 answer
  • Explain the difference between the legal protections a security officer enjoys and the legal protections a police officer receiv
    12·2 answers
  • Which of these tools can best be used as a self assessment for career planning purposes?
    6·2 answers
  • ___________allows you to see what the final web page will look like.​
    10·1 answer
  • Body positioning is an example of what type of communication?
    6·1 answer
  • What is the advantage of learning through story compared to learning through personal experience?
    7·2 answers
  • Need this java code its on zybooks. given two integers as user inputs that represent the number of drinks to buy and the number
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!