FIND YOUR NEXT FEW LINES

The snippet library.

Small, practical examples. Search by task or narrow things down below.

25 snippets foundClear filters
CGetting Started

Name a value that stays fixed

C: Use a constant declaration or the language’s constant naming convention for a fixed limit.

C✓ Tested
CGetting Started

Print a number with two decimal places

C: Format a small decimal value consistently for display.

C✓ Tested
CGetting Started

Read one character from ASCII text

C: Use a valid zero-based index to read the first character.

C✓ Tested
CGetting Started

Read the beginning of a text value

C: Extract or display the first three ASCII characters from a known nonempty string.

C✓ Tested
CGetting Started

Read the first collection element

C: Access index zero only after establishing that the collection is nonempty.

C✓ Tested
CGetting Started

Repeat a fixed number of times

C: Use a counted loop to print three numbered steps.

C✓ Tested
CGetting Started

Repeat while a condition holds

C: Count down while a positive number remains, updating the loop variable on each iteration.

C✓ Tested
CGetting Started

Replace one collection element

C: Update an existing element at a known valid index.

C✓ Tested
CGetting Started

Require two conditions to be true

C: Combine a lower and an upper bound to check whether a value is in range.

C✓ Tested
CGetting Started

Run your first program

C: Start with a complete program that prints one line. Follow the run instructions below.

C✓ Tested
CGetting Started

Store a value in a named variable

C: Give a value a descriptive name and print it.

C✓ Tested
CGetting Started

Update a running count

C: Change a variable after its initial value has been assigned.

C✓ Tested