write a program to display the array elements in reverse
order in c language
Answer Posted / s r samanta
#include<iostream>
using namespace std;
int main()
{
int n, c, j, temp, a[100];
cout<<"Enter the number of elements in array\n";
cin>>n;
cout<<"Enter the array elements\n";
for ( c = 0 ; c < n ; c++ )
cin>>a[c];
if( n%2 == 0 )
c = n/2 - 1;
else
c = n/2;
for ( j = 0 ; j < c ; j++ )
{
temp = a[j];
a[j] = a[n -j - 1];
a[n-j-1] = temp;
}
cout<<"Reverse arry\n";
for( c = 0 ; c < n ; c++ )
cout<<"\n"<< a[c];
return 0;
}
| Is This Answer Correct ? | 1 Yes | 3 No |
Post New Answer View All Answers
What should malloc(0) do?
Explain the concept and use of type void.
What is the usage of the pointer in c?
void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply
What is Dynamic memory allocation in C? Name the dynamic allocation functions.
In c language can we compile a program without main() function?
write an algorithm to display a square matrix.
Differentiate between full, complete & perfect binary trees.
How can I write a function that takes a format string and a variable number of arguments?
What do you mean by scope of a variable in c?
What library is sizeof in c?
Write a code to generate divisors of an integer?
How can I change their mode to binary?
What are header files why are they important?
What are pointers? What are stacks and queues?