Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function called Divide which divides two numbers, and keeps count of how many times the function was called asking to divide by zero.

Write a function called Divide which divides two numbers, and keeps count of how many times the function was called asking to divide by zero. The function has two outputs: z, the division of the two numbers, and times, the number of times the function was called with a divide-by-zero request. In the case of a divide-by-zero request, the resultant should be set to not a number (NaN). Restrictions: The function must make use of a persistent variable. I got most of the code, but eventually, I cannot make it work for the counter part. image text in transcribedimage text in transcribedimage text in transcribed

How many times to divide by zero? Write a function called Divide which divides two numbers, and keeps count of how many times the function was called asking to divide by zero. The function has two outputs: z, the division of the two numbers, and times, the number of times the function was called with a divide-by-zero request. In the case of a divide-by-zero request, the resultant should be set to not a number (NaN). Restriction: The function must make use of a persistent variable. Ex: >> clear all; x=1; y=1; [z,times] = Divide ( x, y) times = [l x#1 ; y=0 ; [z,tines] Divide ( x, y) >> = NaN times = [z,tines] Divide(x,y) >> x-2 ; howmany y-0; = z- NaN times =

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

=+differences in home- and host-country costs of living?

Answered: 1 week ago

Question

=+derived from the assignment will balance the costs?

Answered: 1 week ago