Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What should malloc(0) do?

1058


Explain the concept and use of type void.

1060


What is the usage of the pointer in c?

1042


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

2702


What is Dynamic memory allocation in C? Name the dynamic allocation functions.

1334


In c language can we compile a program without main() function?

1057


write an algorithm to display a square matrix.

2640


Differentiate between full, complete & perfect binary trees.

1052


How can I write a function that takes a format string and a variable number of arguments?

1003


What do you mean by scope of a variable in c?

972


What library is sizeof in c?

1036


Write a code to generate divisors of an integer?

1008


How can I change their mode to binary?

1051


What are header files why are they important?

1043


What are pointers? What are stacks and queues?

1063