Westonci.ca is the ultimate Q&A platform, offering detailed and reliable answers from a knowledgeable community. Our platform connects you with professionals ready to provide precise answers to all your questions in various areas of expertise. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform.
Sagot :
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] << " "; }
Thanks for using our service. We aim to provide the most accurate answers for all your queries. Visit us again for more insights. We appreciate your time. Please revisit us for more reliable answers to any questions you may have. Get the answers you need at Westonci.ca. Stay informed by returning for our latest expert advice.