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
Which mitigation technique would prevent rogue servers from providing false ip configuration parameters to clients?
IrinaVladis [17]
DHCP snooping is a mitigation technique<span> to </span>prevent rogue<span> DHCP </span>servers  <span>from </span>providing false IP configuration parameters to clients.  DHCP snooping<span> is a security feature that acts like a firewall between untrusted hosts and trusted </span>DHCP<span> servers. It is</span><span> a series of techniques applied to improve the security of a </span>DHCP<span> infrastructure. </span>
6 0
3 years ago
Read 2 more answers
Worms often try to disguise from where they are sending data by using a bogus ip addresses instead of using an authorized ip add
Katyanochek1 [597]

If the question is asking whether it is true or false, the answer is false because worms are not responsible for disguising when they are sending data by using bogus ip addresses but it is the Trojan horses in which they are the one responsible for misleading users from the true intent or the real data.

5 0
3 years ago
What are the benefits of using presentations to organize and deliver information?
bearhunter [10]
Hello.

The benefits of using presentations to organize and deliver information are: it keeps things in order, keeps peoples attention longer, and it looks more professional.
4 0
3 years ago
Can you help please ill give branilist
konstantin123 [22]

HTML uses tags to help the computer know what different pieces of content in the web page actually are. Right now we've only learned how to tell the computer that some text is a paragraph, or that part of your website is the body. We've already seen how that affects the way our web pages look and are structured.

(I don't know how it should be organized, but hope this helped)

3 0
2 years ago
When Clara accesses the programs and documents on her computer by way of icons, she is said to be employing
julsineya [31]
Your answer would be D, graphical user interface. Hope this helps!
5 0
3 years ago
Read 2 more answers
Other questions:
  • The process of starting or restarting a computer or mobile device is called __________.
    5·1 answer
  • The ____ contains the computer's "brain," the central processing unit (CPU).
    5·2 answers
  • What is the difference between an embedded image and an attached image
    7·2 answers
  • Why is Abraham called the Father of Believers?
    6·1 answer
  • Sandra is having difficulty with her reading assignment because she does not fully understand the language. Which online tool wo
    6·1 answer
  • Even if you cannot afford it you should donate at least 5 of your earnings to charity true or false
    8·1 answer
  • Your organization uses a type of cryptography that provides good security but uses smaller key sizes and utilizes logarithms tha
    9·1 answer
  • Question 21 pts How many lines should an email signature be? Group of answer choices "5 to 6" "7 to 8" "1 to 2" "3 to 4"
    10·1 answer
  • Any movie/show suggestions??
    7·2 answers
  • Maia is typing her report on meerkats for her biology class.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!