This is a very basic interview question but many get stuck.
Question: Draw the FLOWCHART for the IF statement , and for the WHILE loop.
Answer: The flowcharts are attached.
The if statement is on the left of the picture. So, it checks a condition once and decides whether to do the action of not. If the condition is true, it executes the action and then ends. If the condition is false, it skips the action and goes straight to the end. This means the action either happens once or not at all.
The while loop is on the right of the image. It checks a condition. If True, then it does the action. If condition was true then It loops back to check the condition again instead of ending. This creates a cycle where the action keeps getting performed repeatedly as long as the condition remains true. Only when the condition finally becomes false does the program exit the loop.