Number of Digits
#include <bits/stdc++.h>
using namespace std ;
int count (int n){
//Base case
if (n==0) return 0;
//Recursive case
int smallAns = count(n/10);
//Calculation
return smallAns + 1 ;
}
int main(){
int n ;
cin >> n;
cout << count(n) << '\n';
}
Comments
Post a Comment