Write in C++. Do not use arrays or strings. 2. Happy Numbers: A number (>0) is called
Fantastic news! We've Found the answer you've been seeking!
Question:
Write in C++. Do not use arrays or strings.
Transcribed Image Text:
2. Happy Numbers: A number (>0) is called a happy number, if you start with the given number and arrive at 1 by repeating the following process (as illustrated in the below example): (a) compute the sum of the squares of given number digits (b) if the resultant value is 1, then the number is happy number, else execute point (a) for the newly produced number. 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 number entered by the user is happy number or not for 100 cycles/iterations only. Example: Assume a number 19 Number Computation 12 +92 82 +22 62 + 82 12 +02 +02 Result cycle/iterations 1 19 82 82 68 68 2 100 3 100 1 4 Stop computing further, as the Result obtained is 1. Hence, the number '19' , is a happy number. We achieved this in 4th cycles only. Function Prototype: bool isHappyNumber(int num); Example 01:** *marks: 02 Input: Number: 19 Output: Happy Number Example 02:** *marks: 02 Input: Number: 7 Output: Happy Number Example 03:*** Input: Number: 18 *marks: 02 Output: Sad Number Note: Take input and display output in main function. 2. Happy Numbers: A number (>0) is called a happy number, if you start with the given number and arrive at 1 by repeating the following process (as illustrated in the below example): (a) compute the sum of the squares of given number digits (b) if the resultant value is 1, then the number is happy number, else execute point (a) for the newly produced number. 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 number entered by the user is happy number or not for 100 cycles/iterations only. Example: Assume a number 19 Number Computation 12 +92 82 +22 62 + 82 12 +02 +02 Result cycle/iterations 1 19 82 82 68 68 2 100 3 100 1 4 Stop computing further, as the Result obtained is 1. Hence, the number '19' , is a happy number. We achieved this in 4th cycles only. Function Prototype: bool isHappyNumber(int num); Example 01:** *marks: 02 Input: Number: 19 Output: Happy Number Example 02:** *marks: 02 Input: Number: 7 Output: Happy Number Example 03:*** Input: Number: 18 *marks: 02 Output: Sad Number Note: Take input and display output in main function.
Expert Answer:
Answer rating: 100% (QA)
Here is the screenshot of the program code Screenshot of the output Text Format Code include using n... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
10,000.0 8,000.0 6,000.0 4,000.0 2,000.0 0.0 (2,000.0) (4,000.0) (6,000.0) (8,000.0) (10,000.0) (12,000.0) 01/Oct/17 01/Sep/17 Operating cash flow Investing cash flow Financing cash flow Monthly cash...
-
Joe and Liz are the directors of BuzzMe Pty Ltd, a mobile phone company. Joe had known that the company was in financial difficulties in December 2019 but had assured his fellow director it was just...
-
Write a C++ program that will compare two arrays to test for the same elements and multiplicity. To begin, populate the arrays with the input files, comFile1.txt and comFile2.txt. The elements in the...
-
Is CSCH3CO2 ionic or covalent ? Name it QUESTION 7 Is rubidium dichromate ionic or covalent ? Write its formula QUESTION 8 s copper m suhde soric or covaent write its formula QUESTION 9 Is vanadium...
-
Jessica Chatman is a staff auditor assigned the task of performing tests of internal controls for the JC Automotive Parts engagement. Before she begins testing, Jessica must first determine the...
-
Required information [The following information applies to the questions displayed below.] Hemming Co. reported the following current-year purchases and sales for its only product. Date Activities...
-
Wamser Service Center just purchased an automobile hoist for \($39,000\). The hoist has an 8-year life and an estimated salvage value of \($3,000\). Installation costs and freight charges were...
-
Consider a rectangular fin that is used to cool a motorcycle engine. The fin is 0.15 m long and at a temperature of 250C, while the motorcycle is moving at 80 km/h in air at 27C. The air is in...
-
Mike's Body Shop adjusted trial balance on December 31, 2020, appears in the work sheet as follows: No. Account Debit Credit 101 Cash $ 27,600 124 Shop supplies 1,600 128 Prepaid insurance 3,800 167...
-
Akha Ama Limited is a specialist manufacturer in the tea and coffee industry. It produces and sells two products: speciality Thai tea and Thai coffee. Akha Ama Limited is a small family-owned...
-
Erie Company manufactures a mobile fitness device called theJogging Mate. The company uses standards to control its costs. Thelabor standards that have been set for one Jogging Mate are asfollows: 2...
-
Portfolios are constructed to reduce risk for a given level of economic return. In this context, why would a company be interested in constructing an ecoefficiency portfolio?
-
Information management is the core of any environmental management system. Do you agree with this statement? How important is accounting information in an environmental management system? Outline...
-
Eco-control has five procedural steps.Think of an important corporate environmental intervention (e.g. emission of waste-water). With reference to this corporate environmental intervention, explain...
-
Why should business worry about the environment? How might ecological accounting help reduce such worries? In your answer consider the views of three different stakeholders.
-
Why might deep green environmentalists favour the presentation of corporate information in ecological accounts but reject disclosures in environmentally adjusted financial accounts?
-
Concord Corp. purchased depreciable assets costing $24,600 on January 2, 2020. For tax purposes, the company uses CCA in a class that has a 30% rate. For financial reporting purposes, the company...
-
Why is it important to understand the macro-environment when making decisions about an international retail venture?
-
You are given the following Laplace transform of the output y(t)of a system with input x(t)and Laplace transform X(s): (a) If x(t) = u(t), find the zero-state response y zs (t). (b) Find the...
-
Given the anti-causal signal x[n]= n u[n] (a) Determine its Z-transform X(z), and carefully plot the ROC when = 0.5 and = 2. For which of the two values of does X(e j ) exist? (b) Find the signal...
-
We are interested in the unit-step solu-tion of a system represented by the following difference equation y[n] = y[n 1] 0.5y[n 2] + x[n] + x[n 1] (a) Find an expression for Y(z). (b) Do a partial...
-
Name the various components of a measurement system.
-
Kemico Ltd manufactures a variety of chemicals which it supplies in bulk to industrial customers. Its factory at Gritborough employs 50 people, and its annual turnover in 1995 was 7.5M. During 1995,...
-
Define the term measurement.
Study smarter with the SolutionInn App