Program to accept values into an array and print array in reverse and original format by using three different functions - 100 Most Important C# Programs

100 Most Important C# Programs

78. Program to accept values into an array and print array in reverse and original format by using three different functions.

Code:

#include<stdio.h>

#include<conio.h>

void read_array(int x[]);

void print_array(int y[]);

void rev_array(int z[]);

main()

{

int a[5];

clrscr();

read_array(a);

printf_array(a);

rev_array(a);

getch( );

}

void read_array(int x[])

{

int i;

for(i=0;i<=4;i++)

{

printf(“enter values for a[%d]:”,i);

scanf(“%d”,&x[i]);

}}

void print_array(int y[])

{

int i;

for(i=0;i<=4;i++)

printf(“%d”,y[i]);

}

void rev_array(int z[])

{

int i;

for(i=4;i>=0;i--)

printf(“\n%d”,z[i]);

}