# Thread: Converting a double digit to single digit

1. ## Converting a double digit to single digit

how do you convert a double digit number, to a single digit in C

say, if you have 34 i want it to convert to,

3*10 + 4 does anyone know of a ready-made algo (or code)?

cheers!

2. ## Re: Converting a double digit to single digit

Why do you want to convert it to the algorithm? That ain't exactly a single digit as you stated in your threads title.

4. ## Re: Converting a double digit to single digit

Kedaman that link just shows how to double the integer though.

5. ## Re: Converting a double digit to single digit

Originally Posted by vbleet
Kedaman that link just shows how to double the integer though.
Well the example shows how to do that, but thats not the point. I guessed he was asking for how to convert a string of digits to an integer.

6. ## Re: Converting a double digit to single digit

Originally Posted by deane034
how do you convert a double digit number, to a single digit in C

say, if you have 34 i want it to convert to,

3*10 + 4 does anyone know of a ready-made algo (or code)?

cheers!
You would need to first convert it into a string, then append the multiplication factor to each digit (char) in the string. The simplest way would involve converting each char back into an integer. There's probably some mathematical way of avoiding the second conversion, but I can't think of it right now.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Featured