Happy Numbers: A number (>0) is called a happy number, if you start with the givennumber and arrive at 1 by repeating the following process (as illustrated in the belowexample): (a) compute the sum of the squares of given number digits (b) if the resultantvalue is 1, then the number is happy number, else execute point (a) for the newly producednumber.Note that if a number is not a happy number, there will be an endless loop to this execution.Goal: In this question, you are required to write Function that checks whether the numberentered by the user is happy number or not for 100 cycles/iterations only.Example: Assume a number 19Number Computation Result cycle/iterations19 12 + 9 2
82 1
82 82 + 2 2
68 2
68 62 + 8 2
100 3
100 1
2 + 0 2 +0 2
1 4
Stop computing further, as the Result obtained is 1. Hence, the number ‘19’ , is ahappy number. We achieved this in 4th cycles only.Function Prototype: bool isHappyNumber(int num);Example01:***********************************************************Input:Number: 19Output: Happy NumberExample02:***********************************************************Input:Number: 7Output: Happy NumberExample03:***********************************************************Input:Number: 18Output: Sad NumberNote: Take input and display output in main function.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here