Values in Cilk
Cilk has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
To run the program, compile it with a Cilk-compatible compiler and then execute the resulting binary:
In this Cilk example, we demonstrate various value types and operations:
Strings: Cilk uses C-style strings. We use the
strcat()
function to concatenate strings.Integers and floats: These work similarly to other C-based languages.
Booleans: Cilk uses the C99
<stdbool.h>
header for boolean types. We use the ternary operator to print “true” or “false” based on the boolean expressions.Printing: We use the standard C
printf()
function for output.
Note that Cilk is an extension of C, so it retains most of C’s syntax and features while adding parallel computing capabilities. In this basic example, we haven’t utilized any of Cilk’s parallel features, but they would be useful for more complex, parallelizable computations.