# Thread: I really need some help here

1. ## I really need some help here

Take an unsigned long variable, ask the user for input. When the input is acquired make pair of numbers from the left to right hand side to give the ASCII value of that pair.

Example1:
Input number: 6968676665 (you don’t need to print this, it is just for illustration—69(E), 68(D), 67(C), 66(B), 65(A))
Output: ABCDE
Example2 (in case there is one extra digit… just ignore it.)
Input number: 16968676665
Output: ABCDE
Example3 (in case there is just one digit)
Input number: 6
Output:

2. So, have you tried anything?

3. EDIT: nvm, didn't read properly

4. How are you storing your number...as a string? If that is the case then if you know how to access each element then add those pairing up, in reverse order.

65 = 107 (taking the ASCII equivalent)

Then all you will need to do to get the 'A' character is subtract 42 ( the answer to everything!)

Example:

Say your number started with 65. Then to print and display the letter 'A', just do something like

Code:
`  printf("%c\n", (number[0] + number[1]) - 42);`
Note: number[] is an array of char. You will need to figure out sizing, initialization and looping logic to complete this.

5. Oh, that will not work for all letters, but I will leave the logic up to you to account for all 26 letters.

6. ## hmm

Originally Posted by BEN10
So, have you tried anything?
I've tried this

long integer l = getlongnumber()
while (l >= 10) {
print ascii(l % 100)
l /= 100;
}

and for right to left (using recursion for fun)

print_ascii_code(getlonginteger())

print_ascii_code(long integer l)
if (l >= 10) {
print_ascii_code(l / 100)
print ascii(l % 100)
}

can't get it to work

7. Do you actually have something called 'getlongnumber' defined some place? You really would be better off here using a string.

Quzah.

8. Originally Posted by quzah
Do you actually have something called 'getlongnumber' defined some place? You really would be better off here using a string.

Quzah.

I'm so lost on this. How would you guys do this?

9. Do you know how to work with arrays? There's a FAQ (see the top of the page) on reading lines of input from the user. Read a line of test (your numbers), and convert them to your number/code.

Quzah.

10. ## hmm

Originally Posted by quzah
Do you know how to work with arrays? There's a FAQ (see the top of the page) on reading lines of input from the user. Read a line of test (your numbers), and convert them to your number/code.

Quzah.

Like I said, I don't even know where to start on this. I'm trying to get this done and for some reason nothing is sticking.

11. Well you could start by helping us help you. One more time: Do you know how to work with arrays?

Yes - Use an array to read a string from the user, then walk through the array peeling off numbers.
No - You could something like getchar in a loop, and then just keep track if you've read an even or odd number as you process them. Odd number, treat it is the higher digit of a two digit number (assuming there can't actually be three digit numbers), even, you've got the low digit as well, so do a bit of magic and convert it to a letter.

Quzah.

12. Originally Posted by quzah
Well you could start by helping us help you. One more time: Do you know how to work with arrays?

Yes - Use an array to read a string from the user, then walk through the array peeling off numbers.
No - You could something like getchar in a loop, and then just keep track if you've read an even or odd number as you process them. Odd number, treat it is the higher digit of a two digit number (assuming there can't actually be three digit numbers), even, you've got the low digit as well, so do a bit of magic and convert it to a letter.

Quzah.
The code I posted above is that not even close?

13. Forget code! You're not there yet.

Post up how YOU would do this job, step by step, in steps that show the logic, ie., pseudo code.

We'll work it up with you, from that.

14. I somewhat like these types of exercises, similar to solving Sudoku for me. If you can make heads or tails of this code, you are almost there to solve this:

Code:
```if (number[len - (2 + i)] == 54)
printf("%c", (number[len - (2 + i)] + number[len - (1 + i)]) - 42);
if (number[len - (2 + i)] == 55)
printf("%c", (number[len - (2 + i)] + number[len - (1 + i)]) - 33);
if (number[len - (2 + i)] == 56)
printf("%c", (number[len - (2 + i)] + number[len - (1 + i)]) - 24);
if (number[len - (2 + i)] == 57)
printf("%c", (number[len - (2 + i)] + number[len - (1 + i)]) - 15);```
A bit cryptic and done a bit on purpose, so know your ASCII values! So wrap this within a loop and see what you get.

15. Originally Posted by quzah
just keep track if you've read an even or odd number as you process them. Odd number, treat it is the higher digit of a two digit number
what? how does the number being even or odd effect anything?

EDIT: unless you mean "...keep track if you've read an even or odd number of times..."