Write a program to obtain a number (N) from the user and display whether the is a one digit number , 2 digit number, 3 digit number Or more than 3 digit number
#include <bits/stdc++.h>
using namespace std;
int countDigit(long long n) {
return floor(log10(n) + 1);
}
int main(void)
{
long long n;
cout << "Enter an integer: ";
cin >> n;
cout << "Number of digits : "
<< countDigit(n);
return 0;
}
Enter an integer: 23
Number of digits : 2
Comments
Leave a comment