+ 3

To count number of digits

Input : 789 Output : 3

5th Sep 2017, 3:26 PM
Harsh Tirkey
Harsh Tirkey - avatar
2 Answers
+ 4
#include <iostream> using namespace std; int main() { int x; int count=0; int d=10; cin>> x; do { if(x/d!=0) { count++; d*=10; } else { d=0; } }while(d!=0); cout << count+1 << endl; return 0; }
5th Sep 2017, 3:37 PM
Vahid
Vahid - avatar