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 is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
What is a pointer on a pointer in c programming language?
What are types of functions?
why programs in c are running with out #include
What is scanf_s in c?
write a program fibonacci series and palindrome program in c
what is the difference between class and unio?
What is the description for syntax errors?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
Explain how can you restore a redirected standard stream?
Explain Basic concepts of C language?
What is the difference between call by value and call by reference in c?
What would happen to X in this expression: X += 15; (assuming the value of X is 5)
can anyone suggest some site name..where i can get some good data structure puzzles???
What is the right type to use for boolean values in c?