Count Number of Digits Using C


Once you understand how loops can be used to iterate your process life as a programmer getsĀ  more simpler. There can be so many tricks played around if you can identify all the digits from a given number.

For example:

  • Check whether the last digit is even or odd
  • To print the sum of the digits
  • To print the sum of even number digits used.
  • Check if it starts with 98 and has total number of digits is exactly 10.
  • Check if it is a palindrome, etc.

Similar logical solutions can be designed only if you will be able to successfully identify the digits.


Step #1. Read the number ( declare it long int for large range coverage )

Step #2. Repeat until the last digit.Increase the counter variable

Step #3. Finally display the count.


Would You Mind Sharing?


Be the first to comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.