# Thread: Help solving this problem

1. ## Help solving this problem

Given the declarations:
int n;
char ch1;
char ch2;

and given that n contains a two-digit number, translate n into two single characters such that ch1 holds the higher-order digit, and ch2 holds the lower-order digit.
For example, if n=59, ch1 would equal '5', and ch2 would equal '9'. Then output the two digits as characters in the same order as the original numbers.
(Hint: Consider how you might use the / and % operators in your solution)

Any ideas? Thanks.

2. . .. so the hint is given, what can you do with it?

Code:
```    int n=64;

short a=(n%?)/?;
short b=(n%?);```
Figure that out and your output is 6, 4.

3. ## ...

thanks Oldman47, I couldn't exactly understand how you were trying to solve it but what I ended up doing worked...here is the solution in case you wanna know...
int n;
char ch1;
char ch2;

n = 27;
ch1 = n / 10 + '0';
ch2 = n % 10 + '0';

cout << ch1 << ch2;

Salem- get something better to do.

4. Originally Posted by marcelomdsc
Salem- get something better to do.
Something better than your homework, hopefully.

5. Well I won't be wasting any more time reading the same thing on multiple forums.

6. there's even already a thread on this in this forum...from yesterday, though that person gave the impression it was not a HW assignment.