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
How do I get good at c++ programming?
Why Pointers are not used in C++?
What are structures and unions?
What is setbase c++?
What do you understand by pure virtual function? Write about its use?
What is a float in c++?
Explain the extern storage classes in c++.
write a programme to get a character and thier ASCII value
Explain virtual class?
Define the process of handling in case of destructor failure?
Is c++ proprietary?
Is nan a c++?
what is Member Functions in Classes?
What is the difference between c++ and turbo c++?
Please explain the reference variable in c++?