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
Is c object oriented?
What is the difference between call by value and call by reference in c?
What is sizeof array?
i got 75% in all semester am i eligible for your company
What is the purpose of the following code? Is there any problem with the code? void send(int count, short *to, short *from) { /* count > 0 assumed */ register n = (count + 7) / 8; switch (count % 8) { case 0: do { *to = *from++; case 7: *to = *from++; case 6: *to = *from++; case 5: *to = *from++; case 4: *to = *from++; case 3: *to = *from++; case 2: *to = *from++; case 1: *to = *from++; } while (--n > 0); } }
What is the scope of local variable in c?
What are types of functions?
Explain how do you determine the length of a string value that was stored in a variable?
Explain what is the difference between text files and binary files?
what is a constant pointer in C
i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical
Explain do array subscripts always start with zero?
Explain the Difference between the New and Malloc keyword.
Is sizeof a keyword in c?
Why doesnt the call scanf work?