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 does c value mean?
Can main () be called recursively?
Why is structure important for a child?
write a program to create a sparse matrix using dynamic memory allocation.
Describe how arrays can be passed to a user defined function
What are the types of macro formats?
What are the ways to a null pointer can use in c programming language?
A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(
Can two or more operators such as and be combined in a single line of program code?
What is the difference between char array and char pointer?
What is the function of multilevel pointer in c?
How are structure passing and returning implemented?
What is difference between structure and union in c programming?
What is wrong with this program statement?
How many bytes is a struct in c?