Am trying to move a decimal towards the left side but to be am finding it so difficult. I know am supposed to do a multiplication or even a division but actually I really don’t want to do that thing at all. Anybody of you who has another way that I should use to handle this thing? Am interested in making my program is such a way that when the user keys in a number like 0.34 in decimal, the outcome is in percentage, let us say 34%.https://www.theengineeringprojects.com/2019/11/introduction-to-structures-in-c.html
this is a case of 'yes, you can do that' but 'you should not'. The fastest, bestest way here is to multiply by a power of 10.
you 'can' read the input as a string, parse the string, extract the digits, and format the output.
here, for example, you can do a find() and a substr() on a string to find the '.' and then take everything after it (substr(find('.')+1) would turn "0.34" into "34". Then if you actually NEED to use the number as a value, you have to add another step to convert string to number. All that is way too much hassle most of the time compared to input*100, and ... if the user puts in .345, you get 345, not 34.5. You have to add yet one more step to put the decimal back in there after 2 digits, which you can do, but I will leave that to you to study the sting library for the best way.
> I know am supposed to do a multiplication or even a division but actually I really don’t want to do that thing at all.
> Anybody of you who has another way that I should use to handle this thing?
Something like this, for example, to move the decimal point to the right by one.