Happy Number

Happy Number is a number whose eventual sum of square of it’s digits is equal to 1.

Example 1: 19. 12+92 = 82. 82+22 = 68. 62+82 = 100. 12+02+02 = 1. Hence it is a Happy Number.

C
#include <stdio.h>
#include <math.h>
int main()
{
    int n=0,s=0,r=0,nCopy=0;
    printf("Enter a number: ");
    scanf("%d",&n);
    s=10;
    nCopy=n;
    while(s>9)
    {
        s=0;
        while(n>0)
        {
            r=n%10;
            s=s+(int)pow(r,2);
            n=n/10;
        }
        n=s;
    }
    if(s==1)
    {
        printf("%d is a Happy Number",nCopy);
    }
    else
    {
        printf("%d is not a Happy Number",nCopy);
    }
    return 0;
}
C