Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write and test a C++ main program that: a. Prompts the user for an integer value

ID: 3790741 • Letter: W

Question

Write and test a C++ main program that: a. Prompts the user for an integer value n which represents the number of integers to be read next. b. Create a one dimensional dynamic array with size equal to n. c. Prompt the user to input n integers and place these integers in the array using the traveling pointer technique (2nd version) d. Print out the content of the array, in reversed order, using the traveling pointer technique (1st version). 4. Write and test a C++ main program that: a Prompts the user for an integer value n which represents the number of integers to be read next. b. Create a one dimensional dynamic array with size equal to n. c. Prompt the user to input n integers and place these integers in the array using the traveling pointer technique (2nd version) d. Print out the content of the array, in reversed order, using the traveling pointer technique version).

Explanation / Answer

a)To prompt and get a interger we will use cin and cout command of iorteam libaray.

b)To create one dimentional dynamic array we make use of vector which is of so nature . way to declare a vector is <type_data> is declare then array name[size].

c)for this we start a loop and take input till we get n terms for our 1-D array using travelling pointer.

d) array data is output using for loop using travelling pointer as we did for input

#include<iostream>
using namespace std;
int main(){
int n;
cout<<"Input a number ";
cin>>n;
vector<int> arr[n];
cout<<" Input"<<n<<" number ";
for(int i=0;i<n;i++){
cin>>arr[i];
}
cout<<" your Input"<<n<<" number ";
for(int i=0;i<n;i++){
cout<<arr[i];
}
return 0;
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote