Write a program to perform reversal operation on Array.
/* Program to print reverse order using two array. */
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],b[5],i;
void reverse( int [], int [], int); // prototype
/* Below array taking input from user's. */
printf ("Enter 5 elements :-\n");
for (i=0;i<5;i++)
{
scanf ("%d",&a[i]);
}
reverse(a,b,5); //calling the reverse function.
/* Printing outputs of reversed elemnts in array. */
printf ("Elements after revers are :-\n");
for (i=0;i<5;i++)
{
printf ("%d\n",b[i]);
}
}
void reverse (int x[], int rev[], int size)
{
int i,j=0;
/* Here the logics for reverse. */
for (i=size-1;i>=0;i--)
{
rev[j++]=x[i];
}
}
0 Comments
Thank You ! For your love