Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

#Day47 #100DaysChallenge- Matlab Loops|Finding Number of Digits in Given Number

#Day47-Finding Number of Digits in Given Number
Task:
Write a code to find number of digits in the given number.
78096633
Number of Digits:8

Note: This code can be done using the in-built command. But for the challenge, I am trying to avoid those.

Matlab code


function count=numberofdigits(x)

count=0;

while floor(x)>0
x=x/10;
count=count+1;
end
end



Sample Input and Output
>> numberofdigits(9650)

ans =

     4

>> numberofdigits(9650987654)

ans =


    10
Click here for Video Description







Live Support: t.me/matlabirawen


No comments

Popular Posts

Followers