Adding/ subtracting/multiplying/dividing variables in Turing.
Author |
Message |
Vorpal
|
Posted: Sun Nov 30, 2008 11:11 pm Post subject: Adding/ subtracting/multiplying/dividing variables in Turing. |
|
|
I'm taking a grade 10 computer sciences course and we have just begun the programming component of the course. We have begun by using Turing and I've been given an assignment to create a conversation program using Turing. Long story short, I have to multiply two variables and add that product to another variable. Could somebody please explain to me if this is possible/ how to do it in the simplest terms since I've only been exposed to any form of programming for two days?
Thanks in advance.
P.S- My deepest apologies if I could have found this answer without posting here, I tried the F.A.Q and search button but came up empty. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Sun Nov 30, 2008 11:24 pm Post subject: RE:Adding/ subtracting/multiplying/dividing variables in Turing. |
|
|
The first place to consult for tutorials is the Turing Walkthrough. You could search or browse the Tutorials section of the forum for more specific material.
As for your question -- perhaps an example is in order
Turing: |
var first_number : int
var second_number : int
var product_of_numbers : int
first_number := 5
second_number := 3
product_of_numbers := first_number * second_number
put "the product is: ", product_of_numbers
|
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Vorpal
|
Posted: Mon Dec 01, 2008 12:12 am Post subject: Re: Adding/ subtracting/multiplying/dividing variables in Turing. |
|
|
I actually figured this out on my own about twenty minutes ago, the problem was that I was attempting to us x as a symbol for multiplication and the expression looked like -",x, "x",y, "+",z, "is" ,xxy+z,"."
Which didn't make any sense because instead of the x and y being multiplied it was just 2 duplicate variables next to each otherand then y. After I used * instead of the extra x it all worked out fine. Thanks alot for the example and the link though, I'll be sure to check it out. |
|
|
|
|
|
|
|