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
A chief Information Officer (CISO) is working with a consultant to perform a gap assessment prior to an upcoming audit. It is de
artcher [175]

Answer: (D) Vendor management plan

Explanation:

 The chief information officer (CISO) is basically explain about areas of the improvement to the vendors so that is why vendor management plan should be implemented to address the gap assessment in the upcoming audit.

Chief information officer basically managed all the report that are provided to the department of the audit on the monthly bases.

The vendor management are basically responsible for managing all the upcoming assessment in the audit in an organization.

8 0
3 years ago
"When using BitLocker on a laptop, the laptop should not use standby mode, rather it should use hibernate mode. This is because
Harman [31]

Answer:

This statement is false.

Explanation:

The correct statement should read:

"When using BitLocker on a laptop, the laptop should not use standby mode, rather it should use hibernate mode. This is because Hibernate writes memory to the computer’s disk drive, ****which means the contents of the computer's memory are protected by Bitlocker.****

Standby mode (which is basically putting the computer to sleep) keeps the computer in a very low power state, and memory is maintained and not protected by BitLocker."

Hope this Helps.

6 0
4 years ago
Computers use two different types of memory to operate.
Julli [10]
I only know one which is GB. This is used to store data lie files, software updates, pictures and that kind of thing.
4 0
4 years ago
Read 2 more answers
PLZ sub to me on you tube at RESURGENTZ I would love to reach 100 subs by the end of this year have a great day. I GIVE BRAINLIE
oksano4ka [1.4K]

Answer:

I'll sub for ya!

Explanation:

Consider it done. I hope you reach your goal!

4 0
3 years ago
Read 2 more answers
Which of the following is a malicious program that can replicate and spread from computer to computer?
Marina CMI [18]
An email, duh!

lol j.k def not email, it is a virus.

a trick to remembering this is that a virus can make you and computer sick. 

5 0
4 years ago
Read 2 more answers
Other questions:
  • Define the term entity and give an example of an entity .
    10·1 answer
  • What happened if the offshore team members are not able to participate in the iterations demo due to timezone/infrastructure iss
    12·1 answer
  • What is the danger of open-source software when it comes to military robotics?
    13·1 answer
  • JAVA
    12·1 answer
  • I am fast when im thin, I'm slow when im thick.<br><br>Air is my weakness,<br><br><br>What am I?
    13·1 answer
  • Every Java statement ends with: *<br><br> Period<br> Colon<br> Double quote<br> Semicolon
    11·2 answers
  • All the crtl keys on the keyboard
    8·2 answers
  • Once the data center routes to the destination server that hosts the website, what's the next step in the Internet process?
    12·1 answer
  • What is a computer?write any four features of computer​
    14·2 answers
  • What are the nuclear codes?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!