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

Object-Oriented Programming Fall 2017 LAB 2- Array reversal You have an array of

ID: 3888389 • Letter: O

Question

Object-Oriented Programming Fall 2017 LAB 2- Array reversal You have an array of n entries. n should be a constant integer, as a default set to 20. You need to write 2 loops. The first should start at entry 0 and end at entry n-1, and save the value of the entry number in the array (e.g. AIO] -0, A[ IH , .. A[19h=19). This is for initialization. The second loop should then read through the array entries and swap the outermost entries, moving inwards towards the middle with every iteration (e.g. A[0] and A[19] swap values, then A[I] and A[18] swap, until A[9] and A[10] swap). All this shall run in a single main) routine. Print outputs to the screen. Make sure you go through the code development process .Design the method/algorithm (plain English, pseudo code, flow chart, etc.) Code your algorithm (in C++) Test your code, Does your algorithm work to swap each entry? Analyze your output and prove it worked. Debug your code; If it did not work properly, ask why (from a high level) did it not work? Is it an algorithmic or coding error? Use the debugger to identify the root-cause and fix your code.

Explanation / Answer

Here is your c++ code:

C++ array code:

#include<iostream.h>

#include<conio.h>

void main()

{

int array[20],temp;

clrscr();

for(int i=0;i<20;i++) //to store value into array

{

array[i]=i;

}

cout<<"Output: ";

for(int j=0;j<=19;j++)

{

if(j<10) //to swap array values

{

temp=array[j];

array[j]=array[19-j];

array[19-j]=temp;

}

cout<<array[j]<<" "; //to print array

}

getch();

}

And its pseudo or algo be like:

I hope this solves your problem

Comment if you have any problem in above answer

And please give it a thumbs up it solved your problem :)