write a program to display the array elements in reverse
order in c language

Answer Posted / prajot chougale

#include<stdio.h>

main()
{
int n, c, d, a[100], b[100];

printf("Enter the number of elements in array\n");
scanf("%d",&n);

printf("Enter the array elements\n");

for ( c = 0 ; c < n ; c++ )
scanf("%d",&a[c]);

for ( c = n - 1, d = 0 ; c >= 0 ; c--, d++ )
b[d] = a[c];

for ( c = 0 ; c < n ; c++ )
a[c] = b[c];

printf("Reverse array is\n");

for( c = 0 ; c < n ; c++ )
printf("%d\n", a[c]);

return 0;
}

Is This Answer Correct ?    5 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is size of union in c?

570


Which is more efficient, a switch statement or an if else chain?

570


Differentiate between calloc and malloc.

747


Can you please explain the difference between strcpy() and memcpy() function?

593


What is difference between arrays and pointers?

573






if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.

4485


What is #pragma statements?

583


What is structure padding in c?

616


What is the meaning of c in c language?

586


How can you allocate arrays or structures bigger than 64K?

676


What is the size of empty structure in c?

580


What is binary tree in c?

617


What is the basic structure of c?

549


What are type modifiers in c?

613


What is the best way to store flag values in a program?

573