Consider the following pseudocode function

Mathematics
Tutor: None Selected Time limit: 1 Day

Jun 15th, 2015

Thank you for the opportunity to help you with your question!

a) crunch(5)=60

1st time it will go to else part = 5+crunch(5*10)

again crunch(50) function is executed

2nd time it will go to the else part= 5+ 50 +crunch(500)

again crunch(500) function is executed

since 500>100, it will return 500/100=5


total=5+50+5=60


b) crunch(-24)= will run for infinite times.

in the condition it is only if x>=100;

so every time it will go to the else part and get multiplied by 10, and still remain negative. hence it will not terminated.

precondition can be mod(x)>=100 will eliminate such errors.

Please let me know if you need any clarification. I'm always happy to answer your questions.
Jun 15th, 2015

Studypool's Notebank makes it easy to buy and sell old notes, study guides, reviews, etc.
Click to visit
The Notebank
...
Jun 15th, 2015
...
Jun 15th, 2015
Feb 21st, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer