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 meaning of the word joystick
Roman55 [17]
<span>The meaning of Joystick is the control column of an aircraft</span>
4 0
3 years ago
Read 2 more answers
Why are large commercial companies interested in developing mobile apps for smartphones?
loris [4]
Because they can make a lot of money if they create a popular application.
7 0
3 years ago
What do we call stores in a physical world?
djyliett [7]

Answer:

brick and mortar stores i believe

6 0
3 years ago
I connected to an external hard drive to transfer some photos from my vacation. When I try to drag the photo, it bounces right b
Ilia_Sergeevich [38]
Your answer is D.

Hope this helps and if you could answer the question I just uploaded titled giving brainliest that would be great. Basically, what you have to do is research why the book titled the list of things that will not change and explain why it’s your favorite book based on the message it tells you! Go to my profile and go to questions.
7 0
3 years ago
Assume that the ciphertext C is computed from the plaintext P by C= P ⊕ K1 ⊕ K2 , where K1 and K2 are the encryption key and ⊕ d
Sedbober [7]

Answer:

K1 ⊕ K2 = 9

Explanation:

Since 5 ⊕ K = 12, K must be 5 ⊕ 12 = 9.

But there are supposedly two encryptionkeys, we cannot know their individual value, only that K1 ⊕ K2 = 9.

That makes this a bit weird question.

4 0
4 years ago
Other questions:
  • When you need to cut new external threads on a bolt, what tool should you use?
    7·2 answers
  • Describe a strategy for avoiding nested conditionals. Give your own example of a nested conditional that can be modified to beco
    15·1 answer
  • Which of the following is an example of fine art? 1. fashion 2. interior design 3. painting 4. product design
    7·2 answers
  • An organization has a datacenter that processes highly sensitive information and is staffed 24 hours a day. The datacenter inclu
    12·1 answer
  • Monica wants insert a cover page for her report. She needs to be sure her insertion point is at the beginning of the report.
    7·1 answer
  • Write a program that will sort an array of data using the following guidelines - DO NOT USE VECTORS, COLLECTIONS, SETS or any ot
    10·1 answer
  • How are computers used in education and entertainment? List them.​
    10·1 answer
  • All conduit must be strapped within __ feet of a pull box.
    14·1 answer
  • Why does 5G mmWave require more cells to achieve a better signal?
    10·1 answer
  • Problem Statement − Suppose the problem statement at hand is to contain the attrition that happens in companies worldwide. High
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!