Input a number and display that how many digits it has.
#include <iostream>
using namespace std;
int main() {
int n, amountDigits=1;
cout<<"Enter a number: ";
cin>>n;
int temp = n;
while(temp>9){
amountDigits++;
temp/=10;
}
cout<<amountDigits;
return 0;
}
Comments
Leave a comment