Question

5.43 (10 pts) What does the following program do? #include <stdio.h> 3 unsigned int mystery Cuns igned int a, unsigned int b)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// Sample output

고 CAUsers\Lenovo\Desktop\recursiveadd.exe sers LenovoDesktoptrecursiveadd.exe Enter two positive integers: 3 4 The result isExplanation:

The unsigned int mystery(unsigned int a, unsigned int b) compute multiplication of two integers by Recursive addition method.This takes two integers parameters a and b Where b must be +ve.

for ex:

let us pass a=3, b=4 as values a & b respectively

if we dive into mystery(3,4) function

here b=4

if (1==b) (i.e 1==4) condition fails

so

else part gets executed as

a+mystery(a,b-1) i.e (3+ mystery(3,3)

the above process repeats until b=1 by adding a value

3+3+3+3=12 which is multiplication of 3 by 4 (3*4=12)

Add a comment
Know the answer?
Add Answer to:
5.43 (10 pts) What does the following program do? #include <stdio.h> 3 unsigned int mystery Cuns...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT