Write a complete program that reads in some unknown number ofpositive integers f
ID: 3609656 • Letter: W
Question
Write a complete program that reads in some unknown number ofpositive integers from standard input (keyboard) into a vector.Then output all values to standard output (terminal) in reverseorder (with one space between each value). The user will type a -1to signal that they are through inputting positive integers. Do notstore or output the -1.For example, if the values read in are in this order: 1 3 5 29 then the output would be: 9 2 5 3 1
Do not output anything other than the values in the vector.In other words, do not prompt the user for input. Just assume theuser knows to input some number of positive integers and a -1 tofinish.
Explanation / Answer
please rate - thanks #include #include using namespace std; void load(vector&,int&); void print(vector,int); const int SIZE=100; int main() {int count=0; vector num(SIZE); load(num,count); print(num,count); system("pause"); return 0; } void load(vector& num,int &count) {do{cin>>num[count++]; }while(num[count-1]!=-1); count--; } void print(vector num,int count) {int i,j=1; for(i=count-1;i>=0;i--) {coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.