Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 2: digit sum functional form You already solved this problem without a function in the previous - Programming assignment. The goal now is to

image text in transcribed Question 2: digit sum functional form You already solved this problem without a function in the previous - Programming assignment. The goal now is to see the advantage of writing functions over plain code to solve a single task. Given a two digit positive integer number, write a C++ function named GetDigitSum to calculate the sum of the two digits mathematically. This means you must extract each digit mathematically without using string or character manipulations or any other C++ library. Do the following: 1. Write your algorithm as code comments. (20 points) 2. Implement your function ( 60 points): 2.1 Document what your function does as a code comment. Follow slide 15 of the lesson (5 points) 3. In your main program, test your function for the number 28,49,50,89 by calling it for every number. in the order given. Note that this may be either fully or partially set up al ready in CodeCheck. ( 20 points) . 3.1 Now you must see that if you didn't write a function for this, you'd end up writing the same set of code for each number repeatedly. Hint: You will have to use integer division and remainder operations. */ //Replace ... with your code or comment. Hit enter key to get more vertical space The test cases may fail if you print (std::cout) anything other than expected inside your function. Do it in your IDE if you want to use std:: cout for debugging purpose. */ // PLAN: //Follow the UMPIRE technique and write your PLAN below. Please comment out your writing. ... // IMPLEMENT: \#include // Enter your function documentation below. Please comment out your writing. ... double GetDigitSum(int a_number) \{ // REVIEW: int main(int argc, char *argv[]) \{ int number =34; std: : cout GetDigitSum(number) std: : endl; // Print a call to your function for each data point in the order given in the problem statement. // See example above. ... return ; \} \}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

1844804526, 978-1844804528

More Books

Students also viewed these Databases questions