Answer to Question #234511 in C++ for Supriya

Question #234511

An array is type of data structure that stores the elements in contiguous block of memory, create an array with name "list" and size of an array is N. your task is to print the array elements in an reverse order.


list-[1,2,3,4,5)


output 5,4,3,2,1


Note: use function concept to process the array elements and print it in the reverse order.


Reverse array has the following parameter


int list[n]


return int


1
Expert's answer
2021-09-07T14:15:56-0400
#include <iostream>
using namespace std;


#define N	5
main()
{
	int list[N] = {1,2,3,4,5};
	int r;
	
	cout<<"\n\tArray in original form: ";
	for(r=0;r<N;r++) cout<<list[r]<<", ";
	
	cout<<"\n\n\tArray in REverse order: ";
	for(r=N-1;r>=0;r--) cout<<list[r]<<", ";
	
}




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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS