I have made some modifications to eliminate reading from keyboard and the datafile, and the code prints the array in reverse order. So logic is fine.
We will need to look at the data.
One thing to check is right after you have read your data file, print them out to see if they have been read properly.
If that works, print the array on entry to reverse, and just before exit.
All this is to locate where the problem is.
Once you know where the problem is, the problem scope will be reduced significantly.
Don't know if myprogramminglab lets you do all that, but you can do these tests on your own compiler.
Here's the modified code.
using namespace std;
int *reverse(const int *, int);
cin >> N;
if(N > 50 || N < 0)
// int *arr1 = new int[N], index;
int *arr1=new int[N];
datafile.open("data.txt", ios::in | ios::out);
for(index = 0; index < N; index++)
datafile >> arr1[index];
temp = reverse(arr1,N);
for(index = 0; index < N; index++)cout << temp[index] << endl;
int *reverse(const int *arr1, int N)
int index = N-1;
arr2 = new int[N];
for(int count = 0; count < N; count++)
arr2[count] = arr1[index];
after the due date my teacher told me what was wrong with it apparently the entire problem was the .txt which I erroneously thought you had to have, ty for your help
you're welcome! :)
college - Write a C++ program to fill an array with 6 numbers, and then reverse...
computer science - Write a method printBackwards that prints an array of ...
computer programming c++ - write a program that can read 10 interger values into...
computer programming - write a program that can read 10 interger values into an ...
Computer Science - I need help with this question please! Please write me step ...
assembler language - write an assembly language subordinate count according to ...
Computer programming - problem: Write a program that accepts your first name ...
C++ programming computer - I'm having some trouble trying to program these ...
pseudocode - Assume that your family has 10 members. Assume further that each ...
math - don break a 4x7 array into a 2x7 array and another array. what is the ...