Challenge!!!! Write a C program to count the number of digits for a given number. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Challenge!!!! Write a C program to count the number of digits for a given number.

The digit's length can be of any number ranging from 01 to 20.Never use functions to directly read the characters from the number. Write a logic so that it can print out the length. You can write it in any language.

7th Dec 2017, 4:43 AM
®️ahul Mathews™️
®️ahul Mathews™️ - avatar
7 Answers
7th Dec 2017, 5:08 AM
RZK 022
RZK 022 - avatar
+ 6
my scanf doesnt work does anyone know whats wrong? https://code.sololearn.com/c2a95DX0YgmB/?ref=app
7th Dec 2017, 4:57 AM
Louis
Louis - avatar
+ 5
C++ solution, which could easily work in C. https://code.sololearn.com/c83V3ZB4b5wS/?ref=app
7th Dec 2017, 6:51 AM
Eric Blinkidu
Eric Blinkidu - avatar
7th Dec 2017, 11:35 PM
LunarCoffee
LunarCoffee - avatar
+ 2
https://code.sololearn.com/cNt1G3Wh8KPk/?ref=app
7th Dec 2017, 6:03 AM
...
+ 1
@Louis your code is working fine, but to print the length of a larger number you need to change the data type of the variable to long or long long
7th Dec 2017, 5:32 AM
®️ahul Mathews™️
®️ahul Mathews™️ - avatar
7th Dec 2017, 7:40 AM
Pritivi Vignesh