May 06, 2024, 05:51:29 PMLatest Member: Pleryhalax
BoutCheetah » Forum » Other » Spam » is this right pseudocode

is this right pseudocode

Started by Pokeh, April 11, 2014, 10:16:26 PM

Previous topic - Next topic

Pokeh

April 11, 2014, 10:16:26 PM Last Edit: April 11, 2014, 10:24:34 PM by Pokeh
QuoteWrite a program to read in a series of integers and print out only the odd numbers over 1000.  At the end the program should also print out how many such numbers were found.

It's a hell of a lot easier than the assembler problem..

i have this so far:

in x
While
  if x>1000 then load y
  SET x=y/2
  If x=1 then Add 1 to counter
End While
Print X
Print Counter
Halt


Basically if the numbers going to be odd and I continue to divide by 2, I should get a 1. If that's the case and the numbers over 1000 then it adds 1 to the counter.

How do I get it to say x=x/2 until it reaches 0 or 1?


EDIT: i fixed it. just tell me if its right or not

Pokeh


Copyright © ZylonGaming 2009 - 2024
-Terms of Use-