Author Topic: Count Number of digits using log in c++ ?  (Read 856 times)

kathir

  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
Count Number of digits using log in c++ ?
« on: November 25, 2011, 02:16:46 pm »
Here is the code to count the number of digits in c++ using log function:

Code:
//Source Code Listing

#include <math.h>

int CountNumberOfDigits_usingLog(int n)
{
   return (int) (log10((double)n) + 1);
}


 


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