Branching with if and else in Cilk is straightforward.
To compile and run the Cilk program:
Note that you need parentheses around conditions in Cilk, and the braces are required for multi-line blocks.
Cilk, being an extension of C++, supports the ternary operator ?:, which can be used for simple conditional expressions. However, for clarity and consistency with the original example, we’ve used full if statements.