Saturday 1 November 2014
25. Write a program using pointers to read an array of integers and print its elements in reverse order.
25. Write a program using pointers to read an array of integers and print its elements
in reverse order.
PRO-25:
#include<stdio.h>
#include<conio.h>
void main()
{ int
n,a[10],i;
int
*ptr;
clrscr();
ptr=a;
printf("\nEnter
Array Size : ");
scanf("%d",&n);
printf("\nEntet Array Element 1 by 1\n");
for(i=0;i<n;i++)
{ printf("\nEnter [%d] Element
: ",i+1);
scanf("%d",ptr+i);
}
printf("\n
Reverse Array Interger is :");
for(i=n-1;i>=0;i--)
{ printf("\n%d",*ptr+i);
}
getch();
}
OUTPUT:
Enter Array Size :
4
Entet Array
Element 1 by 1
Enter [1] Element
: 11
Enter [2] Element
: 12
Enter [3] Element
: 13
Enter [4] Element
: 14
Reverse Array Interger is :
14
13
12
11
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment