#include <stdio.h>

#include <curses.h>
#include <stdlib.h>
void main()
{

	int n,*p,i,j,temp;
	printf("\n\n Pointer : Sort an array using pointer :\n");
 
	printf("--------------------------------------------\n");
	   
   
   printf(" Input the number of elements to store in the array : ");

	scanf("%d",&n);
	p=(int *) malloc(n*2);

	if(p==NULL||n==0){
		printf("\nMEMORY ALLOCATION UNSUCCESSFUL:\n");
		printf("Input of elements in the array must be possitive! Try again.");
		exit(0); 
	}
       
	for(i=0;i<n;i++)
{

		printf("\nENTER NUMBER %d: ",i+1);

		scanf("%d",p+i);

	}

	for(i=0;i<n;i++)
{

		for(j=0;j<n;j++)

		{

			if(*(p+i)<*(p+j))

			{

				temp=*(p+i);
*(p+i)=*(p+j);
				
*(p+j)=temp;

			
}
		
}
	
}

printf("\nTHE SORTED NUMBERS ARE:\n");

	for(i=0;i<n;i++)

		printf("%d ",*(p+i));


}
