Anonymous
Anonymous asked in Computers & InternetProgramming & Design · 1 month ago

What is the pseudocode of a program that outputs all the numbers that are divisible by 3 from 0 to 100 (inclusive)?

4 Answers

Relevance
  • 1 month ago

    The smart way to do this is to loop in steps of 3 using a "for loop".  Almost every programming language going back to early FORTRAN supports this (notable exceptions being pure functional programming languages, since they don't loop.)

    for i = 0 to 100 in steps of 3:

        output (i)

    end for

    If, for some reason, your instructor doesn't want you to use a for statement in your pseudocode, you can translate that to a while loop.  (It's a good exercise to do so anyway, just to hammer down exactly what a for statement does.)

    i = 0

    while i <= 100 do

        output (i)

        i = i + 3

    end while

  • Anonymous
    1 month ago

    n = 0

    while 3n <= 100

         output 3n

  • 1 month ago

    These numbers start with 3 and end with 99. And there are 33 of them.

    for n = 3 while n<100 do the stuff then add another 3

  • EddieJ
    Lv 7
    1 month ago

    From 0 to 100:

    ... If number is divisible by 3 then output number

Still have questions? Get your answers by asking now.