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
A developer designed a process in UiPath Studio that is best-suited for a simple and linear process. Which Studio workflow type
Gala2k [10]

Question options:

State Machine

Flowchart

Sequence

Global Exception Handler

Answer:

Sequence

Explanation:

Uipath is an RPA(Robotic process automation) software that is used by IT professionals and business executives in automating routine or iterative tasks in an organization. Uipath process projects incorporate different workflow types which include :sequence, flowchart, state machine and global exception handler. The sequence workflow type is used for simple linear projects that are not very complex and occupies a single activity block.

3 0
2 years ago
Html code to hyperlink file​
Dovator [93]

Answer:

<p>Want to contact a specific staff member?

Find details on our <a href="contacts.html">contacts page</a>.</p>

Explanation:

7 0
3 years ago
A car manufacturer uses'simulation software during the design process for a new car. Which of the
exis [7]

D I,II and III is the answer i think

5 0
2 years ago
Interchanges of ideas in forums and internet news groups are functions of which domain?
Anarel [89]
I believe that the answer to the question provided above is that the  <span>Interchanges of ideas in forums and internet news groups are functions of the information domain.</span>
Hope my answer would be a great help for you.    If you have more questions feel free to ask here at Brainly.
5 0
3 years ago
A single inheritance model means: * A) A class can only have one parent class (superclass) B) A class can only have one child cl
Troyanec [42]

Answer:

The answer is A)

Explanation:

In programming languages like java you can only use single inhertance meaning a class can only inherit attributes from one class. But in other languanges like C you can have multiple inhertance

6 0
3 years ago
Other questions:
  • Knowledge flows from the information that has been generated. Which of the following does not necessarily flow from information
    15·1 answer
  • When talking about changes related to information​ technology, the text identifies three interrelated changes that are responsib
    8·1 answer
  • The first version of the SMTP protocol was defined in RFC 821. The current standard for SMTP is defined in RFC 5321 considering
    11·1 answer
  • 4.17 LAB: Varied amount of input data ( C++)
    5·1 answer
  • You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?
    10·1 answer
  • What are your undertale + au ships?
    15·1 answer
  • How do you render and export files on blender
    6·1 answer
  • You can perform an in-place upgrade to Windows 7 from both Windows XP and Windows Vista
    11·2 answers
  • A line graph is a great tool for showing changes over time. Why is a line graph better than other graphs at showing this type of
    6·1 answer
  • Consider the following variable declarations and initializations.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!