Question: PLEASE CODE IN C DO NOT COPY Exercise 2. (50 points) Happy Numbers A happy number is a number defined by the following process: Starting

PLEASE CODE IN C DO NOT COPYPLEASE CODE IN C DO NOT COPY Exercise 2. (50 points) Happy

Exercise 2. (50 points) Happy Numbers A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number either equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1 . Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers. For example, 13 is a happy number since 12+32=1+9=1012+02=1+0=1 And 85 is an unhappy number since 82+52=64+25=8982+92=64+81=14512+42+52=1+16+25=4242+22=16+4=2022+02=4+0=442=1612+62=1+36=3732+72=9+49=5852+82=25+64=89,whichisarepeatedresult. It can be shown that if a number is an unhappy number, it will reach 4 in the above process. This can be used to check whether a number is an unhappy number. Our job is to write code to check whether a positive integer is a happy number. Part of the code is already given. As shown below, we only need to fill in the code under TODO. Note to print out the intermediate numbers to match the expected output. \#include \#include int main() \{ int n; printf ("n="); scanf ("%d", \&n ); int m=n; //TODO //add code below

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!