#include<conio.h> |
| #include<stdio.h> |
| #include<stdlib.h> |
|
| int main() |
| { |
| int *ptr,i,n; |
| clrscr(); |
| printf( "Enter the no of elements:" ); |
| scanf( "%d" ,&n); |
| ptr=(int *)malloc(sizeof(int)*n); |
| if(ptr==NULL) |
| { |
| printf( "Not enough memory" ); |
| exit( 1 ); |
| } |
| for(i= 0 ; i<n; i++) |
| { |
| printf( "Enter %d element : " ,i+ 1 ); |
| scanf( "%d" ,&ptr[i]); |
| } |
| printf( "Array in original order\n" ); |
| for(i= 0 ; i<n; i++) |
| { |
| printf( "%d\n" ,ptr[i]); |
| } |
| printf( "Array in reverse order\n" ); |
| for(i=n -1 ; i>= 0 ; i--) |
| { |
| printf( "%d\n" ,ptr[i]); |
| } |
| getch(); |
| return 0 ; |
0 comments:
Post a Comment