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
kaheart [24]
3 years ago
6

5.18 LAB: Output numbers in reverse Write a program that reads a list of integers, and outputs those integers in reverse. The in

put begins with an integer indicating the number of integers that follow. For coding simplicity, follow each output integer by a comma, including the last one. Ex: If the input is: 5 2 4 6 8 10 the output is: 10,8,6,4,2, To achieve the above, first read the integers into a vector. Then output the vector in reverse.
Computers and Technology
1 answer:
Rina8888 [55]3 years ago
6 0

Answer:

In C++:

#include<iostream>

#include<vector>

using namespace std;

int main(){

   int len, num;

   vector<int> vect;

   cout<<"Length: ";

   cin>>len;  

   for(int i = 0; i<len;i++){

       cin>>num;

   vect.push_back(num);}

   vector<int>::iterator iter;

   for (iter = vect.end() - 1; iter >= vect.begin(); iter--){

       cout << *iter << ", ";}    

}

Explanation:

This declares the length of vector and input number as integer

   int len, num;

This declares an integer vector

   vector<int> vect;

This prompts the user for length  

cout<<"Length: ";

This gets the input for length  

   cin>>len;  

The following iteration gets input into the vector

<em>    for(int i = 0; i<len;i++){</em>

<em>        cin>>num;</em>

<em>    vect.push_back(num);}</em>

This declares an iterator for the vector

   vector<int>::iterator iter;

The following iterates from the end to the beginning and prints the vector in reverse

<em>    for (iter = vect.end() - 1; iter >= vect.begin(); iter--){</em>

<em>        cout << *iter << ", ";}</em>

<em />

<em />

You might be interested in
What is zenmap typically used for? how is it related to nmap? describe a scenario in which you would use this type of applicatio
slava [35]

Zenmap is the graphical User Interface representation for NMAP Security Scanner. It is an open-source program designed to make NMAP easy for starters to use. Typically, it is used to collect and identify a list of hosts, OS, as well what services are running on them by using a port scanning tool. It is used specifically for the scanning and vulnerability phase of ethical hacking.

A network administrator who wishes to audit all the devices on a specific IP scheme in a network can use NMAP. The admin can go ahead and scan the ports to know exactly which ports are closed and which are opened.






8 0
3 years ago
90 POINTS Hazel is working with a database to help determine if the company she works for is making or losing money. Hazel has o
VikaD [51]

Answer:

a

Explanation:

5 0
2 years ago
Read 2 more answers
In high-tech fields, industry standards rarely change.<br> True <br> False
Sophie [7]

Answer: false

Explanation:

5 0
3 years ago
Write a loop that subtracts 1 from each element in lowerScores. If the element was already 0 or negative, assign 0 to the elemen
Verdich [7]

Answer:

Replace <STUDENT CODE> with

for (i = 0; i < SCORES_SIZE; ++i) {

       if(lowerScores.at(i)<=0){

           lowerScores.at(i) = 0;

       }

       else{

           lowerScores.at(i) = lowerScores.at(i) - 1;

       }  

   }

Explanation:

To do this, we simply iterate through the vector.

For each item in the vector, we run a check if it is less than 1 (i.e. 0 or negative).

If yes, the vector item is set to 0

If otherwise, 1 is subtracted from that vector item

This line iterates through the vector

for (i = 0; i < SCORES_SIZE; ++i) {

This checks if vector item is less than 1

       if(lowerScores.at(i)<1){

If yes, the vector item is set to 0

           lowerScores.at(i) = 0;

       }

       else{

If otherwise, 1 is subtracted from the vector item

           lowerScores.at(i) = lowerScores.at(i) - 1;

       }  

   }

Also, include the following at the beginning of the program:

<em>#include <vector></em>

8 0
3 years ago
Online databases allow you access to material you may not be able to find when using popular search engines like Google. Select
Anna007 [38]

Answer:

True

Explanation:

6 0
3 years ago
Other questions:
  • What is 450 g of flour a measure of?
    11·1 answer
  • __________ involves determining what qualities are to beused to perform project activities.
    9·1 answer
  • Sales representatives want to capture custom feedback record details related to each Account. The sales reps want to accomplish
    12·1 answer
  • Which of the following accessories would you use to create a drawing? A. Calculator B. Notepad C. Paint D. WordPad
    14·2 answers
  • 4.5 code practice computer science
    5·1 answer
  • If I got a monitor and kept my garbage laptop could I play games on max graphics?
    13·1 answer
  • 80. A .......... is used to read or write data.<br>A. CD B. VDU C. ROM D. RAM​
    6·1 answer
  • A Development team begins work on a new software application and decides to involve the client’s IT experts to ensure that secur
    12·1 answer
  • Write long answer to the following question. a. Define microcomputer. Explain the types of microcomputers in detail.​
    5·2 answers
  • What is your impression on the subject fundamentals of database systems?​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!