Thursday, July 9, 2009

C++ code that reads natural numbers and display how many ones, ten's ,hundreds thaousands & so on in the given

c++ code that reads natural numbers and display how many ones, ten's ,hundreds thaousands %26amp; so on in the given numbers

C++ code that reads natural numbers and display how many ones, ten's ,hundreds thaousands %26amp; so on in the given
What you need to work with are division and modulus.





for example: my_number = 1234





1234%10 = 4 #This is your number of ones


1234%100 =34 so, to separate the 3, we see we need to get rid of the 4 and move the 3 over. We can do this using division in between.





1234%10 = 4 //Ones place


1234/10 = 123


123%10 = 3 //Tens place


and so on
Reply:you can read in xp=


long double data type=(-1.7*pow 10,(-4936)) to


1.7*pow 10,(4936)


No comments:

Post a Comment