Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What is c++ good for?

1059


Explain how to initialize a const data member.

1120


What is the size of a vector?

1133


What is flush c++?

1006


What is pair in c++?

1061


why and when we can declar member fuction as a private in the class?

2068


Why are arrays usually processed with for loop?

1230


What is the difference between structure and class?

1253


What is the difference between method overloading and method overriding in c++?

1143


What is ofstream c++?

1081


Will the following program execute?

1030


Explain the different access specifiers for the class member in c++.

994


How do you define/declare constants in c++?

1045


Explain about vectors in c ++?

1022


Mention the purpose of istream class?

1105