Computer Science Canada

odd even counting :D

Author:  soulgnat [ Wed Jan 21, 2004 3:34 pm ]
Post subject:  odd even counting :D

this program will identify whether number is odd or even...

code:

var oddeven: array 1..7 of string
var enternum: array 1..7 of int

var x:int:=1
put "Enter 7 numbers"
for i:1..7
put "Enter your # ",i,"pick"
get enternum (i)
if enternum (i) mod 2 not=0 then
    oddeven (i):="odd"
elsif enternum (i) mod 2= 0 then
    oddeven (i):="even"
end if
x:=x+1
end for

delay (300)
cls

for i:1..7
    locate (i,10)
    put enternum (i)
    locate (i,20)
    put oddeven (i)
end for
[/code]

Author:  shorthair [ Wed Jan 21, 2004 4:06 pm ]
Post subject: 

Please change your avatar to a smaller size , it makes the forum look messey , it occupys almost half of the page , Very Happy Thanks , nice program by the way , i take it your new to turing ?

Author:  kalin [ Wed Jan 21, 2004 5:28 pm ]
Post subject: 

please pick a smalled avatar or crop it down. Adn that is kinda neat too. The program I mean...

Author:  the_short1 [ Mon Feb 09, 2004 5:20 pm ]
Post subject: 

If you want a action to be executed only every odd repetition of loop try this:

code:
var num : int := 1
loop
if num mod 2 not= 0 then
% What you want done every second repitition of loop
end if
num := num + 1
end loop


i like your program only thing is it tells you which ones are odd and even...
i though i would do an extension of you work....

yea it took me a while to figure out how to make it go every odd repition.... untill i CjGauhan told me in class (use MOD) Duh!! .... i got 91% but i didn;t always listen to teacher cuz i had my headphones blaring...

I hope you have great suceess in your class... Computer Sciences is fun if you are able to listen to musik

Author:  Andy [ Mon Feb 09, 2004 9:18 pm ]
Post subject: 

y would u need array for this?


: