I have a project that reads: “There will be no conditional statements (if, switch, or,…).” I’m not sure if this includes for and while loops, since both technically run on conditions. Could I get away with saying that they’re “conditional loops” instead?
I have a project that reads: There will be no conditional statements (if, switch,
Share
It would probably be acceptable to use loops (
for,while,…), but you would need to check with the project author. I tend to treat loops and conditional statements separately, as they usually have different purposes…ifandswitchwill make a choice out of a list of options. They only run once.forandwhileare typically designed to run a piece of code multiple times.Of course this is only a generalisation, and everyone probably has a different opinion, but I certainly treat them differently because they have different primary purposes.
For extra credit, Wikipedia seems to agree. The If Statement is a conditional operator, and the For Loop is an iteration statement.