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


Please Help Members By Posting Answers For Below Questions

How do I get good at c++ programming?

849


Why Pointers are not used in C++?

822


What are structures and unions?

792


What is setbase c++?

829


What do you understand by pure virtual function? Write about its use?

781


What is a float in c++?

749


Explain the extern storage classes in c++.

783


write a programme to get a character and thier ASCII value

2810


Explain virtual class?

790


Define the process of handling in case of destructor failure?

797


Is c++ proprietary?

815


Is nan a c++?

874


what is Member Functions in Classes?

838


What is the difference between c++ and turbo c++?

806


Please explain the reference variable in c++?

812