Computer Science Canada

can i make a basic unkown int?

Author:  cheese188 [ Wed Apr 08, 2009 7:52 pm ]
Post subject:  can i make a basic unkown int?

if i had the variable

Turing:
var n : int
n :=                %how can i make n unkown




BooHoo just thought id put that in cause it looks cool


Mod Edit: Remember to use syntax tags! Thanks Smile
code:
[syntax="turing"]Code Here[/syntax]

Author:  saltpro15 [ Wed Apr 08, 2009 7:57 pm ]
Post subject:  RE:can i make a basic unkown int?

what do you mean by unknown? like a random number? if so, use
Turing:

var num := Rand.Int (1,100)

for example, that will create a random integer between 1 and 100

Author:  cheese188 [ Wed Apr 08, 2009 8:07 pm ]
Post subject:  Re: can i make a basic unkown int?

not really i need like an integer that can be anything a user enters so i can use it in an if statement
with another integer like

code:
Turing:
var [color=blue]n[/color] : int
[color=blue]n[/color] := Rand.Int (1, 3)

var [color=blue]g[/color] : int
[color=blue]g[/color] := %this is the part I am confused about

if [color=blue]n [/color]= 1 then
   put [color=red]"kauf"[/color] ..     
   get [color=blue]g[/color]
end if

if [color=blue]g[/color] = [color=blue]n[/color] then
   put "[color=blue]jadg"[/color]
end if


kind of like a question, if n = 1 then it say's kauf then whoever enters g
then if the g they entered is the same as n then it say's jadg
what i need to know is how to make g 3 different values or any value
hope i explained it well enough[syntax=""][/syntax]

Author:  saltpro15 [ Wed Apr 08, 2009 8:30 pm ]
Post subject:  RE:can i make a basic unkown int?

what's with all the extra brackets? I don't think they're necessary...

just use a get statement
code:

var n : int
get n
if n = 1 then
%do something
elsif n = 2 then
% do something else

Author:  cheese188 [ Wed Apr 08, 2009 8:36 pm ]
Post subject:  Re: can i make a basic unkown int?

oh its so simple i did not think of putting a get statement before if statement
thanks a lot that's going to complete my program

Author:  saltpro15 [ Wed Apr 08, 2009 8:38 pm ]
Post subject:  RE:can i make a basic unkown int?

no problem

Author:  Siavash [ Sat Apr 11, 2009 7:35 am ]
Post subject:  RE:can i make a basic unkown int?

I do
Turing:

var n :int
randint (n, 0, 10000)


: