Computer Science Canada Could anyone help please? |
Author: | jhdho0204 [ Thu Dec 09, 2010 6:06 pm ] | ||
Post subject: | Could anyone help please? | ||
What is it you are trying to achieve? <Replace all the <> with your answers/code and remove the <>> Let n be a positive integer consisting of the digits dk?d1d0. Write a program that reads in a value of n and then prints its digits in a column, start with d0. Fro example if n = 3467, then the program should print 7 6 4 3 What is the problem you are having? <Answer Here> Describe what you have tried to solve this problem <Answer Here> Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) <Answer Here>
Please specify what version of Turing you are using <Answer Here> This is the question i got a problem with.. could someone help? |
Author: | Tony [ Thu Dec 09, 2010 6:14 pm ] |
Post subject: | RE:Could anyone help please? |
What kind of a problem do you have with this question? |
Author: | jhdho0204 [ Fri Dec 10, 2010 9:57 am ] |
Post subject: | RE:Could anyone help please? |
I have problem with coding.. I'm not sure... could someone type in a code for me or something? |
Author: | Insectoid [ Fri Dec 10, 2010 10:31 am ] |
Post subject: | RE:Could anyone help please? |
Of course you're having a problem with your coding. If you were having issues with your breakfast, you wouldn't be here would you? We're not writing even a single line for you though. |
Author: | Tony [ Fri Dec 10, 2010 12:38 pm ] |
Post subject: | RE:Could anyone help please? |
@jhdho0204: I'm sure that you are able to solve this question. If n=1234, describe, step by step, how you would get the answer. |
Author: | jhdho0204 [ Fri Dec 10, 2010 6:37 pm ] |
Post subject: | RE:Could anyone help please? |
Well my code is: var n: int put "Type in an integer: ".. get n for 1.. n n mod 2= 1 put n end for |
Author: | Insectoid [ Fri Dec 10, 2010 6:50 pm ] |
Post subject: | RE:Could anyone help please? |
Quote: n mod 2 = 1
You're not even trying. This doesn't do anything. I'm not sure if this will even compile. Mathematically, how do you get the least significant digit in a number? The second least? Once you figure that out, it's a walk in the park to output it. Here's a hint: You CAN (and probably should) use modulus. |
Author: | Searing [ Tue Dec 14, 2010 10:34 am ] |
Post subject: | Re: Could anyone help please? |
Or you could get the number as a string instead of an integer. var num: string Then use string operations to get the result you want. |