Sunday, October 11, 2009

Help me with pascal, need to understand loops better. also how to write a program that executes the following?

check if 'n' is between 1 and 100


then run a loop to print all the even numbers only





so something like this perhaps:


check if n %26lt;1%26gt;100;








please at least help me understand loops!!!!

Help me with pascal, need to understand loops better. also how to write a program that executes the following?
The first check is simple (my pascal is rusty so the syntax my not be exactly right)


If n%26gt;= 1 and n%26lt;=100 then


' write out the even numbers


for i = n to 100


if i mod 2 = 0 then print out the number


next


end if





The mod or modulus operator divides n by 2 but gives the remainder. Since even numbers are all divisible by 2, then you have it when its remainder is 0.



home theater

No comments:

Post a Comment