C program to print all disarium numbers between 1 to 100In this program, we need to print all disarium numbers between 1 and 100 by following the algorithm as given below: ALGORITHM:main()
sumOfDigits(num)
calculateLength(int n)
PROGRAM:Output: Disarium numbers between 1 and 100 are 1 2 3 4 5 6 7 8 9 89 Happy NumberA number is said to be happy if it yields 1 when replaced by the sum of squares of its digits repeatedly. If this process results in an endless cycle of numbers containing 4, then the number will be an unhappy number. Let's understand by an example: Number = 32 3^{2}+ 2^{2} = 13 1^{2} + 3^{2} = 10 1^{2} + 0^{2} = 1 In this example, we split 32 to get the sum of squares of its digits which forms another number (13), we replace 32 by 13 to continue this cycle until result 1. We found 32 a happy number. If the above cycle for any number results 1 then that number will be a Happy number otherwise that will be an unhappy number resulting 4, 16, 37, 58, 89, 145, 42, 20,?? Some Happy numbers are 7, 28, 100, 320 etc.
Next TopicC Programs
