Starting Out with C++: Early Objects (9th Edition)
Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 12, Problem 13PC
Program Plan Intro

Digits Sums of Squares and Cubes

Program Plan:

  • Include the required header files to the program.
  • Define the function prototype.
  • Define the “main ()” function. Inside this function,
    • Set the field width to print the string “Number”.
    • Set the field width to print the string “Square”.
    • Set the field width to print the string “Cube”.
    • Set the field width to print the string “Sum”.
    • Loop 1000 times using “for” loop.
      • Find the square of a number and store it in a variable “square_Num”.
      • Find the cube of a number and store it in a variable “cube_Num”.
      • Call the function “sum_Of_Digits ()” by passing “num” as an argument. Store the returned value in a variable “sum”.
      • Check if the sum of digits of “square_Num” and sum of digits of “cube_Num” are equal.
        • Print the value of “num”, “square_Num”, “cube_Num” and “sum”.
  • Give function definition for “sum_Of_Digits ()”. Inside this function,
    • Declare required variables “numberString”, and “digitSum”.
    • Print the value of “number”.
    • Find the sum of digits using “for” loop.
      • Find the sum and store it in a variable “digitSum”.
    • Return the value.

Blurred answer
Students have asked these similar questions
P1 P2 P3 P4 A pentagonal number is one that corresponds to dots arranged into a pentagon. Above are the first four pentagonal numbers and their pentagons. The pentagonal number PN has sides made of N dots. When you count the dots for a pentagonal number, include the dots for the inner pentagons. So to figure out how many dots PN has, find out how many P(N-1) has and add the dots for the new sides of size N. P1 = 1, P2 = 5, P3 = 12, P4 = 22 Figure out a recursive formula for PN and then write a function that implements it. That is, implement pentagonal() using recursion. pentagonal(1) -> 1 pentagonal(2) -> 5 pentagonal(3) -> 12
In computational geometry, often you need to find the rightmost lowest point in a set of points. Write the following function that returns the rightmost lowest point in a set of points:# Return a list of two values for a pointdef getRightmostLowestPoint(points):Write a test program that prompts the user to enter the coordinates of six points and displays the rightmost lowest point.
Baby Names: Each year, the government releases a list of the 10,000 most common baby namesand their frequencies (the number of babies with that name). The only problem with this is thatsome names have multiple spellings. For example, "John" and ''.Jon" are essentially the same namebut would be listed separately in the list. Given two lists, one of names/frequencies and the otherof pairs of equivalent names, write an algorithm to print a new list of the true frequency of eachname. Note that if John and Jon are synonyms, and Jon and Johnny are synonyms, then John andJohnny are synonyms. (It is both transitive and symmetric.) In the final list, any name can be usedas the "real" name.EXAMPLEInput:Names: John (15), Jon (12), Chris (13), Kris (4), Christopher (19)Synonyms: (Jon, John), (John, Johnny), (Chris, Kris), (Chris, Christopher)Output: John (27), Kris (36)

Chapter 12 Solutions

Starting Out with C++: Early Objects (9th Edition)

Ch. 12.3 - Prob. 12.11CPCh. 12.3 - Prob. 12.12CPCh. 12.4 - What is the output of the following program?...Ch. 12 - A(n)___________is represented in memory as an...Ch. 12 - The____________ statement is required before the...Ch. 12 - A(n)____________is written in your program as a...Ch. 12 - Prob. 4RQECh. 12 - The______________ is used to mark the end of a...Ch. 12 - Prob. 6RQECh. 12 - Prob. 7RQECh. 12 - Prob. 8RQECh. 12 - Prob. 9RQECh. 12 - Prob. 10RQECh. 12 - Prob. 11RQECh. 12 - Prob. 12RQECh. 12 - Prob. 13RQECh. 12 - Prob. 14RQECh. 12 - Prob. 15RQECh. 12 - Prob. 16RQECh. 12 - Prob. 17RQECh. 12 - Prob. 18RQECh. 12 - Write a function whose prototype is char...Ch. 12 - #inc1ude iostream using namespace std; int main()...Ch. 12 - #include iostream using namespace std; int main()...Ch. 12 - #include iostream using namespace std; int main()...Ch. 12 - #inc1ude iostream #inc1ude string using namespace...Ch. 12 - #inc1ude iostream #inc1ude cstring using namespace...Ch. 12 - #inc1ude iostream using namespace std; int main()...Ch. 12 - #inc1ude iostream #inc1ude string using namespace...Ch. 12 - #include iostream #inc1ude cstring using namespace...Ch. 12 - #include iostre4m #inc1ude cstring using namespace...Ch. 12 - Each of the following programs or program segments...Ch. 12 - Soft Skills 30. You are a member of a...Ch. 12 - Prob. 1PCCh. 12 - Prob. 2PCCh. 12 - Prob. 3PCCh. 12 - Prob. 4PCCh. 12 - Name Arranger Write a program that asks for the...Ch. 12 - Prob. 6PCCh. 12 - Prob. 7PCCh. 12 - Prob. 8PCCh. 12 - Prob. 9PCCh. 12 - Password Verifier Imagine you are developing a...Ch. 12 - Prob. 11PCCh. 12 - Check Writer Write a program that displays a...Ch. 12 - Prob. 13PCCh. 12 - Dollar Amount Formatter Modify Program 12-13 by...Ch. 12 - Word Separator Write a program that accepts as...Ch. 12 - Prob. 16PCCh. 12 - I before e except after c A friend of yours who is...Ch. 12 - User Name Write a program that queries its...Ch. 12 - String Splitter Write a function vectorstring...Ch. 12 - Palindromic Numbers A palindromic number is a...
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education