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

How many levels deep can include files be nested?

654


What is action and transformation in spark?

600


Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix

1523


How reliable are floating-point comparisons?

632


int i=10; printf("%d %d %d", i, i=20, i);

1018






What are the types of assignment statements?

633


How can you tell whether two strings are the same?

836


Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon

5464


Why c is called object oriented language?

592


How is a null pointer different from a dangling pointer?

560


What is the difference between a string and an array?

711


How does sizeof know array size?

634


write a program to concatenation the string using switch case?

1563


When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.

1533


how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.

1214