Dudeney Number

Dudeney Number is a natural number which is a perfect cube and cube root is equal to the sum of its digits.

Example 1: 19683. 273 = 19683. Also 1+9+6+8+3 = 27. Hence it is a Dudeney Number.

Example 2: 74088. 423 = 74088. But 7+4+0+8+8 ≠ 42. Hence it is not a Dudeney Number.

C
#include <stdio.h>
#include <math.h>
int main()
{
    int n=0,r=0,sum=0,cRoot=0,nCopy=0;
    printf("Enter a number: ");
    scanf("%d",&n);
    nCopy=n;
    cRoot=(int)cbrt(n);
    while(n>0)
    {
        r=(int)n%10;
        sum=sum+r;
        n=n/10;
    }
    if(cRoot==sum)
    {
        printf("%d is an Dudeney Number",nCopy);
    }
    else
    {
        printf("%d is not an Dudeney Number",nCopy);
    }
    return 0;
}
C