![]() |
| ||
| Converting digits..need help! Hi everyone!I've started to learn C++ couple of months ago and having some trouble with the code i'm trying the write.. I have to write a function that converts every digit of the parameter to zero,except 2.And number of digits is unknown.. I made this but its's output is always 0.Even i enter a number that contains 2...I'll be glad if you could help..Thanks:) #include<iostream> |
| ||
| Re: Converting digits..need help! I'd be glad if you could read all the intro threads which describe how to post code. |
| ||
| Re: Converting digits..need help! What I could get out of your unformatted code was if(remainder==2) remainder=2; if(remainder!=2) remainder=0; should be better : if(remainder==2) remainder=2;leave this away-->if it IS 2 why set it to 2 ? if(remainder!=2) remainder=0;-->+-OK, because if you want to print 2 it will print 0 |
| ||
| Re: Converting digits..need help! Lines 11,12. n is 0 after them and also i don't get why u use for not while and why u need that int i |
| ||
| Re: Converting digits..need help! ok,thanks for your help.. i'll fix it.. |
| ||
| Re: Converting digits..need help! You say that you don't know the exact number of digits. Then why not he input to the function be a string such that
Hope that i am not twisting the question.:twisted: |
| ||
| Re: Converting digits..need help! Thank you so much zalezog..I've made it:)..I used string and it's way much easier... |
| All times are GMT -4. The time now is 8:46 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC