I need help please, how can I write a program to count the number of digits of an integer the user entered ?

5 ビュー (過去 30 日間)
For example, I asked the user to input a number and he entered 5984, how can I write a program to count how many digits it has (which is 4)? Thank you.

採用された回答

madhan ravi
madhan ravi 2020 年 9 月 23 日
編集済み: madhan ravi 2020 年 9 月 23 日
strlength(abs(5984) + "")

その他の回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 9 月 23 日
An alternative
n = floor(log10(5984)+1)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by