Param is a course instructor of
c++ programming and currently
he is teaching conversions to his
students. He started with the
basic programs and now he
want to introduce some
complex problems. Before
starting the complex problems,
he wants to start with high
difficulty level problem, such as:
counting the digits of a number.
Help Mr. param to write a
program which will accept one
integer argument and returns
count of digits of that argument
using class to basic conversion.
#include <iostream>
using namespace std;
int main()
{
int x, n = 1;
cin >> x;
while ((x /= 10) > 0)
n++;
cout << n;
return 0;
}
Comments
Leave a comment