Starting from:

$30

CS3-Split List Balance Solved

ZyBook Chapter 4

215 = 32,768 and 3+2+7+6+8 = 26

Write a program product-digit-sum.cpp that computes ab = n and then the sum of the digits in n.  Whatever progress you have made in implementing this program will be discussed at the next synchronous class meeting.  

You should not use the math module.  Your program should have a function pow(a, b) that implements the computation for ab  manually.    Although the user may enter negative numbers, this should be treated as invalid / unsupported inputs.  So, pow(a, b) takes positive integers only.

Sample Output:

user@machine:solution$ ./pds

a: 2 b: 15

2^15 = 32768

Sum Of Digits: 26

More products