Consider a flowchart that starts with a number n. It checks if n is greater than 10. If yes, it adds 5 to n. Otherwise, it subtracts 3 from n. What is the final value if n = 8?
Follow the decision step carefully: Is 8 greater than 10?
Since 8 is not greater than 10, the flowchart subtracts 3 from 8, resulting in 5.
In flowcharts, which symbol is used to represent a decision point where the flow splits based on a condition?
Think about the shape that looks like a tilted square.
The diamond shape represents a decision point where the flow branches based on a yes/no or true/false condition.
Two flowcharts perform the same task: checking if a number is even or odd. Flowchart A uses a decision to check number % 2 == 0. Flowchart B uses a decision to check number % 2 != 1. Which statement is true?
Recall that number % 2 gives the remainder when divided by 2.
Both conditions check if the remainder is zero, so both correctly identify even numbers.
A flowchart starts with input x. It then checks if x is positive. If yes, it doubles x. If no, it sets x to zero. Finally, it outputs x. How many steps (including start and end) does this flowchart have?
Count each shape: start, input, decision, process, output, end.
The flowchart has: start, input, decision, process (double or set zero), output, and end steps, totaling 6 steps.
A flowchart is designed to calculate the factorial of a number n. It initializes result = 1, then uses a loop from 1 to n multiplying result by the loop counter. However, the flowchart's loop counter starts at 0 instead of 1. What is the impact of this error?
Recall that multiplying by zero results in zero.
Starting the loop at 0 means the first multiplication is by zero, making the result zero regardless of n.