Guide · Basic examples

Basic Examples – a Guide to the Tasks

Here are practice tasks on programming basics, arranged in the order the material is learned: from data and operators, through branching and loops, to arrays, strings, functions, vectors and maps. Every page has tasks with an example of input and output, and many also have a hint or a solution.

The tasks are mostly in C and C++ (some in Java). They are meant for students from grade 5, especially those preparing for school and municipal informatics competitions.

  • Grades 5–8 and secondary school
  • C, C++, Java
  • Tasks with solutions
  • Competition preparation
How to work: for every topic first read the lesson (the link is at the top of every page), then solve 3–5 easier tasks without looking at the solution. Open the solution only when your program works for the example from the task – and then compare the ideas. At the end of every page there is a short quiz and a list of common mistakes.

Some lessons linked below are available only in Serbian for now. They are marked (SR).

1 First steps: data, operators, branching

Input and output, formulas, integer division and the remainder, and then decisions with if.

2 Repetition: loops

Counters, sums, averages, reading until the end of input, and then a loop inside a loop.

3 More data: arrays, matrices, sorting

When data has to be remembered and processed several times.

4 Text and functions

Working with strings and splitting a program into smaller parts.

5 The C++ library: vectors and maps

Arrays of variable length and dictionaries (key → value).

6 After the basic examples

When you solve most of the tasks in this guide, continue with algorithms and competition tasks.

Suggested order

  1. Data and arithmetic operators
  2. Operators (SR)
  3. Branching
  4. Loops
  5. Nested loops
  6. Arrays
  7. Matrices
  8. Sorting
  9. Strings
  10. Functions
  11. Vectors and maps (SR)
Note: strings and functions can also come earlier (after loops) – it depends on the order in which you learn them at school or in a club.

Useful external resources