Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How many digits are in the number N? We can solve this by counting the rightmost digit and removing it, continuing until all digits have

How many digits are in the number N? We can solve this by counting the rightmost digit and removing it, continuing until all digits have been removed so that n is 0.To remove one digit of N you can use integer division of N/10, which can be implemented in matlab with the function iderive(N,10). Using as source of inspiration the code below, write a function to compute the number of digits in a number. Testing with N=345, the result should be 3 digits. Do the driver code, function code and output in matlab.

image text in transcribed

P#18 % splitDigits2.m clc, clear Write the function N-input('Enter integer N '); N1-int16(N); % also int8, int32, int64 while N1>0 N1.derive(N1,10); % performs integer division end fprintf('The number of digits of %d is %d ",N, c); % Note: N1-N1/10 doesn't work in matlab as it % doesn't produce the quotient of an integer 96 division

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions