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 a character in c++?

995


Is swift better than c++?

890


What are its advantages and disadvantages of multiple inheritances (virtual inheritance)?

1144


Write a program which uses functions like strcmp(), strcpy()? etc

1044


Describe Trees using C++ with an example.

1087


Is oops and c++ same?

994


What do you mean by overhead in c++?

1028


Do you need a main function in c++?

1074


Difference between an inspector and a mutator

1270


Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

2526


What gives the current position of the put pointer?

941


Can recursive program be written in C++?

1181


Is c++ high level programming language?

1072


What is buffer and example?

940


Explain one method to process an entire string as one unit?

1507