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 is hashing in c language?

1326


Explain how can you determine the size of an allocated portion of memory?

1119


What is the size of a union variable?

1058


How do you use a pointer to a function?

1095


What is the difference between functions abs() and fabs()?

1161


Can you please explain the difference between malloc() and calloc() function?

1131


What does c value mean?

1207


How do I convert a string to all upper or lower case?

1136


A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers

1211


What does %p mean c?

1081


What is the purpose of macro in C language?

1127


State the difference between x3 and x[3].

1118


How can I insert or delete a line (or record) in the middle of a file?

1023


How do I get a null pointer in my programs?

1120


How important is structure in life?

1093