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
leonid [27]
3 years ago
6

Write a program that reads a list of integers, and outputs those integers in reverse. The input begins with an integer indicatin

g 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 10the 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:
Sergeu [11.5K]3 years ago
7 0

Answer:

The program in C++ is as follows:

#include <iostream>

#include <vector>

using namespace std;

int main(){

   vector<int> intVect;

   int n;

   cin>>n;

int intInp;

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

 cin >> intInp;

 intVect.push_back(intInp); }

for (int i = n-1; i >=0; i--) {  cout << intVect[i] << " "; }

 return 0;

}

Explanation:

This declares the vector

   vector<int> intVect;

This declares n as integer; which represents the number of inputs

   int n;

This gets input for n

   cin>>n;

This declares intInp as integer; it is used to get input to the vector

int intInp;

This iterates from 0 to n-1

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

This gets each input

 cin >> intInp;

This passes the input to the vector

 intVect.push_back(intInp); }

This iterates from n - 1 to 0; i.e. in reverse and printe the vector elements in reverse

for (int i = n-1; i >=0; i--) {  cout << intVect[i] << " "; }

You might be interested in
What is the advantage of using CSS?
Naily [24]

Answer:

c) It creates a better-structured document

Explanation:

The layout of a web page is better controlled. Style (CSS) kept separate from structure (HTML), means smaller file size. Reduced file size means reduced bandwidth, which means faster loading time.

3 0
4 years ago
Read 2 more answers
Explain the first to four generations of a computer​?
goblinko [34]

Answer:

<u>First generation are</u>

a)they are unreliable

b)they are very costly and

c)huge in size

<u>Second generation are</u>

a)they use a transistor

b)smaller in size compared to first generation

c)they are faster than the first generation

<u>Third generation are </u>

a)its more reliable than the first generation and the second generation

b)faster than first generation and the second generation

c)consume less electricity

<u>Fourth generation are</u>

a) they are very cheap

b)they are very small in size

c)they are portable and reliable

Explanation:

explanation is in the answer

3 0
3 years ago
Select the correct answer.
goblinko [34]

Answer:

b

Explanation:

8 0
3 years ago
Java uses ____ to implement method lookup.A) a jump tableB) an inheritance treeC) restricted accessD) polymorphism
sashaice [31]

Answer:

D) polymorphism

7 0
4 years ago
Discuss four uses of computer ​
PtichkaEL [24]

1. It helps to the development of our career.

2. Through the internet, we can know the facts which were happening all over the world

3. Computer can be use as a calculator too

4. We can store any kind of information.

<h3>Hope This Helps You ❤️</h3>
6 0
3 years ago
Read 2 more answers
Other questions:
  • Write a small program that asks the user how many asterisks it should print out. The user responds with a number, then the progr
    8·1 answer
  • He primary purpose for attackers to send port scanning probes to hosts is to identify which ports are open. true false
    5·1 answer
  • True or False, A column is a horizontal arrangement for items of information.
    15·1 answer
  • When Russ opened a website on his browser, he saw an error that the site was not compatible with the browser version he was runn
    12·1 answer
  • How does one award the brainliest???? will give brainliest.
    8·2 answers
  • Dr.Sanchez is creating a quiz for a history class. It will have true or false questions. What kind of variable will be needed to
    10·2 answers
  • Dash is a collection of sequentially arranged slides put together in the from of a file​
    8·1 answer
  • Write a Python program to: ask the user to enter the price of an item. Note: use a while loop to check the validity of the price
    11·1 answer
  • In a food chain are living creatures that eat organisms from a diferente population?
    13·2 answers
  • Who would win in a fight, Noble 6 from halo reach or Master Chief??
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!