Can somebody tell me how this can be changed to accept and print doubles. It works for only integers. I've tried changing the int's to double and the%d to %f but it giving me errors

Code:
#include<stdio.h>
#include<math.h>
main(){    

              int a,b,c;
int i,j,k,p;
int *aptr;
int nrows, ncols; 
printf("How many rows would you like store?\n ");
  scanf("%d", &nrows);
  printf("How many columns would you like to store?\n ");
  scanf("%d", &ncols);
  printf("Enter the number of nearest neighbours p: ");
  scanf("%d", &p);
int row, col;
int Total=nrows*ncols;
int **rptr =(int**)malloc(nrows * sizeof(int *));
if (rptr == NULL)
{
puts("\nFailure to allocate room for pointers");
exit(0);
}   

/* we now allocate the memory for the array */
 aptr =(int*)malloc(Total* sizeof(int));
if (aptr == NULL)
{
puts("\nFailure to allocate room for the array");
exit(0);
}
/* and now we 'point' the pointers */
for (k = 0; k < nrows; k++)
{
rptr[k] = aptr + (k * ncols);
}
 for(i=0 ; i<Total; ++i) 
    {
    printf("Enter data row wise: ");
    scanf("%d", &aptr[i]);
    }
printf("\n\nAnd now we print out the array\n");
for (row = 0; row < nrows; row++)
{
for (col = 0; col < ncols; col++)
{
printf("%d \t", rptr[row][col]);}
printf("\n\n");
getchar();

       }   free(rptr);
       free(aptr);  }