Reverse the values of an Array

Asked By 160 points N/A Posted on -
qa-featured

Hi All

I need to write a program that will show the reverse order of an array’s elements.

What will be code for reversing the values of an array?

For example: if array = 5,8,12,19,25

Then program will show the out put as:

25,19,12,8,5

Any help would really be appreciated.

SHARE
Best Answer by MarkJason
Answered By 0 points N/A #88408

Reverse the values of an Array

qa-featured

All you need to do is to take these 5 numbers from the user and save them in an array. Firstly you will show the array in original order means with original index. After that you will show the array in reverse order, means you will start from the last index and one by one you will decrease the index instead of increasing.

Answered By 140 points N/A #88409

Reverse the values of an Array

qa-featured

How we can reverse the index of an array??????????????????

Answered By 160 points N/A #88411

Reverse the values of an Array

qa-featured

Dear Sahil

I need more help. I am confused about the index of an array. How I will calculate the index of an array and how I will reverse?

Waiting

Answered By 0 points N/A #88412

Reverse the values of an Array

qa-featured

You will declare an array with index 5 as: num[5];

Then you will show the numbers of array as

 

for(i=0,i<5,i++)

cout<<num[i];

 

To show in reverse order you will write code as:

for(i=4,i>=0;i–)

cout<<num[i];

 

I don’t have C++ compiler at the moment. Try this with proper statements in compiler. If you don’t get the true result, please send me your code. So I can help you more.

Best Answer
Best Answer
Answered By 0 points N/A #88413

Reverse the values of an Array

qa-featured

#include<iostream.h>

#include<conio.h>

void main()

{

clrscr

int num[5],I;

 

for(i=0,i<5,i++)

{

Cout<<”enter the number”<<endl;

Cin>>num[i];

 

}

count<<”n the array in actual order”<<endl;

 

for(i=0,i<5,i++)

cout<<num[i];

 

count<<”n the array in reverse order”<<endl;

for(i=4,i>=0;i–)

cout<<num[i];

 

getch();

}

Answered By 160 points N/A #88414

Reverse the values of an Array

qa-featured

Thanks a lot Mark Jason

It really helps me out to understand fully the concept of array and arrays with indexing.

 

Regards

Login/Register to Answer

Related Questions