Author Topic: Turbo C - Count Number of digits  (Read 987 times)

kathir

  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
Turbo C - Count Number of digits
« on: November 25, 2011, 02:13:13 pm »
Here is the code to count the number of digits of a given number using Turbo C

Code:
//Source Code Listing


int CountNumberOfDigits(int n)
{
   int numdgits = 0;
   do
   {
      n = n / 10;
      numdgits++;
   } while(n > 0);
   return numdgits;
}

« Last Edit: November 25, 2011, 02:18:35 pm by kathir »

 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1