60 745
Assignments Done
97,8%
Successfully Done
In April 2018

Answer to Question #24199 in C++ for Nourh

Question #24199
Suppose I have an array of ints called numbers that has 5 values in it. Write code that reverses the order of the values in the array, such that the value that was last will now appear first, and vice-versa.
Expert's answer
# include <iostream>

using namespace std;

void reverse(int ar[5]){
int loc;
loc=ar[0];
ar[0]=ar[4];
ar[4]=loc;

loc=ar[1];
ar[1]=ar[3];
ar[3]=loc;
}
void print(int ar[]){for(int i=0;i<5;i++) cout<<"ar["<<i<<"]="<<ar[i]<<"& ";cout<<endl;}
int main(){
int ar[5]={1,2,3,4,5};
print(ar);
reverse(ar);
print(ar);

system("PAUSE");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions