Write a program that will count the number of digits in an
input integer up to value MAX_VALUE (2147483647). Thus, for
an input of 5837 the output should be
4 digits
Make sure that your program works for the numbers 0, 1, and
10. For the number 0, the output should be
1 digit
Answer Posted / sandeep mannarakkal
I have another suggestion for the above,
int iInputNumber;// This number is used for collecting input from user.
int nCount = 1;
while ( iInputNumber /10 )
{
iInputNumber = iInputNumber/10;
nCount ++;
}
cout << nCount << endl; // nCount will have the count of digits.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is a character in c++?
Is swift better than c++?
What are its advantages and disadvantages of multiple inheritances (virtual inheritance)?
Write a program which uses functions like strcmp(), strcpy()? etc
Describe Trees using C++ with an example.
Is oops and c++ same?
What do you mean by overhead in c++?
Do you need a main function in c++?
Difference between an inspector and a mutator
Write a program that takes a 5 digit number and calculates 2 power that number and prints it.
What gives the current position of the put pointer?
Can recursive program be written in C++?
Is c++ high level programming language?
What is buffer and example?
Explain one method to process an entire string as one unit?