Answers for "find the number of digits of a given integer n ."

C++
0

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;
}
Posted by: Guest on February-06-2022

Code answers related to "find the number of digits of a given integer n ."

Browse Popular Code Answers by Language