Check whether the given number is Happy Number or not.




#include <stdio.h>
#include <math.h>

void main() {
int temp;
int number;
int sum = 0;
int new_num;

printf("Enter number: ");
scanf("%d", &number);

temp = number;
do {
while(number != 0) {
int digit;
digit = number%10;
new_num += pow(digit,2);
number = number/10;
}
number = new_num;
new_num = 0;
}
while(number >= 9);

if(number == 1) {
printf("%d is happy number\n", temp);
}
else {
printf("%d is not happy number\n", temp);
}

}