Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

count digits function in c++ code example

Example: how to find how many digits a number has in c++

#include <iostream>
#include <cmath>

unsigned int getNumberOfDigits (int i)
{
    return i > 0 ? log10((double) i) + 1 : 1;
}

int main()
{
	std::cout << "Number of digits: " << getNumberOfDigits(/*Example*/6738) << std::endl;  
	return 0;
}

Tags:

Typescript Example

Related

yaml for storing api data python code example python keep only last element in list code example convert string array into arraylist code example append data to specific column pandas code example keeps saying ModuleNotFoundError: No module named 'mysql' code example merge arrays based on identical elements in swift code example git display ignored files code example nstimer in swift code example view opened ports ubuntu code example update pip command prompt code example socket.io ignore origin code example cypress default viewport iphone code example

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy