reverse array using function

#include<stdio.h>
int reversearray(int n)
{
    int i , j ,k, a[1000], num;

    num = n;

    printf(" Enter the elements of the array : \t");
    for(j=0;j<num;j++)
    {
        scanf("%d",&a[j]);
    }

    i=j-1;
    j=0;

    while(i>j)
    {
        k = a[j];
        a[j] = a[i];
        a[i] = k;

        j=j+1;
        i=i-1;
    }
    printf(" \n\n The reverse of the array is :\t");
    for(j=0;j<num;j++)
    {
        printf("\n%d\t",a[j]);
    }
    return 0;

}


int main()
{
    int n , x;

    printf(" Enter the Size Of The Array : ");
    scanf("%d",&n);

    x = reversearray(n);

    return 0;

}

OUTPUT :



For Other Programs Visit The WebSite:-   https://www.techapurba.com/

Follow Me On Social Media :-

For tech related videos visit my other website :- https://apurbatechinfo.blogspot.com/

Post a Comment

0 Comments