Program to print array elements and their address in reverse order using pointer


#include<stdio.h>
#include<conio.h>

void adress(int *[]);
void values(int *[]);

int main()
{
int a[5],i;
int *b[5];
printf("enter 5 elements \n");
for(i=0;i<5;i++)
{
scanf("%d",&a[i]);
b[i]=&a[i];
}
printf("\n the elements in reverse order are \n");
values(b);
printf("\n the adress of elements are \n");
adress(b);
getch();
return 0;
}

void adress(int *x[])
{
for(int i=4;i>=0;i--)
printf("\t%x",x[i]);
}
void values(int *y[])
{
for(int i=4;i>=0;i--)
printf("\t%d",*y[i]);
}








0 comments:

Post a Comment