Can you give me tips on how to make a flowchart? I can’t seem to find ways to set counters and accumulators.?

For example, how do I test the primality of a number? Give me just a hint so that I would be able to print prime numbers from 1 to n using a flowchart. Just a hint.

3 Answers

  • 6 months ago

    You create the "flow" of data. Often you are left with a two state answer such as true/false, on/off, right/wrong, etc. You simply create a branch that handles each state until you reach the end where a conclusion has been reached. In cases where there are more than two states, you begin branches that handles each of the possible scenarios. Each decision is like an "if statement" where "if" at that junction the answer is true, you follow another path on what to do, or if the answer is "blue", you create a path on what to do for an answer of blue.

    • Login to reply the answers
  • 6 months ago

    A prime number is one which only has two divisors: itself and 1. So you iterate through the numbers 1..z, and count the number of divisors.

    Pseudocode to find if z is prime or not:

    count = 0

    for x = 1 to z:

    ... if (z MOD x == 0):

    ... ... count = count + 1

    ... end if

    end for

    if (count == 2):

    ... print (z + " is prime")

    end if

    • Login to reply the answers
  • 6 months ago

    Use arrows and boxes for decisions and actions

    • Login to reply the answers
Still have questions? Get your answers by asking now.