Search
 
SCRIPT & CODE EXAMPLE
 

CPP

find number of digits in a number

floor(log10(n) + 1);
Comment

find the number of digits of a given integer n .

#include <bits/stdc++.h>
using namespace std;
//use c++ 11
int main(){
    string n;
    cin>>n;
    int s = stoi(n);
    if(s<0) cout<<n.size()-1;
    else 
    cout<<n.size();
	return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: stp 
Cpp :: labs c++ 
Cpp :: template design pattern 
Cpp :: result += a +b in c++ meaning 
Cpp :: program in c++ for simple interest rate 
Cpp :: c++ sigabrt 
Cpp :: c++ How can I make a std::vector of function pointers 
Cpp :: qt c++ thread example 
Cpp :: Patrick and Shopping codeforces in c++ 
Cpp :: stack in c++ data structure 
Cpp :: read large files part by part in C++ 
Cpp :: 7 9 C:UsersAliyahDocumentsshut up.cpp [Error] expected unqualified-id before string constant 
Cpp :: void linux java 
Cpp :: how to delay text in c++ console app 
Cpp :: add comment in c/c++ 
Cpp :: What will be the values of variables p, q and i at the end of following loop? int p = 5; int q = 18; for(int i=1;i&lt;5;i++) p++; --q; 
Cpp :: log like printf c++ 
Cpp :: android call custom managed method from native code 
Cpp :: c++ power operator 
Cpp :: cicli informatica c++ 
Cpp :: Overloading IO Stream 
Cpp :: how to declare a function in c++ header file 
Cpp :: random c++ 
Cpp :: how a function gives a pointer as parameter c++ 
Cpp :: void pointer c++ 
Cpp :: binary add using strings 
Cpp :: friend class c++ 
C :: rename c 
C :: c random list 
C :: curl authorization header 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =