Guide · Example tasks
Example Tasks – a Guide by Topic
Here are example tasks with solutions in C, C++, Java and Python, arranged by topic in the order they are learned: from data and operators, through branching and loops, to arrays, functions and algorithms.
The examples are suitable for practice after a lesson, for preparing for tests and as an introduction to competitions.
- Primary and secondary school
- C, C++, Java, Python
- Tasks with solutions
Some lessons linked below are available only in Serbian for now. They are marked (SR).
1 Basic examples
The first tasks in the order they are learned: data and operators, branching, loops, arrays and matrices, sorting, strings, functions, vectors and maps. The order and tips for working are given in the guide to basic examples.
Guide: Basic examples
The order of topics, tips for working and what to solve first.
Open lesson →Data and arithmetic operators
The starting page: data types and formulas.
Open lesson →Operators – examples (SR)
Integer division, remainder and conversions.
Open lesson →Branching – examples
Tasks with if, else and switch.
Open lesson →Loops – examples
Tasks with the for, while and do-while loops.
Open lesson →Nested loops – examples
Tables, patterns and going through pairs of numbers.
Open lesson →Arrays – examples
Reading, processing and searching arrays.
Open lesson →Matrices – examples
Two-dimensional arrays in tasks.
Open lesson →Sorting – examples
Ordering an array and binary search.
Open lesson →Strings – examples
Processing text, searching and replacing characters.
Open lesson →Functions – examples
Parameters and return values.
Open lesson →Vectors and maps – examples (SR)
vector and map in C++ through tasks.
Open lesson →2 Algorithm examples
Once you master the basic examples: mathematical algorithms, complexity, recursion, combinatorics and backtracking. More details are in the guide to algorithm examples.
Guide: Algorithm examples
The order of topics and the connection with the algorithm lessons.
Open lesson →Algorithms – examples
GCD, prime numbers, factorization.
Open lesson →Improving complexity (SR)
How to replace a loop with a formula.
Open lesson →Recursive algorithms – examples
Tasks that are solved with recursion.
Open lesson →Combinatorial problems – examples (SR)
Generating variations, subsets and permutations.
Open lesson →Backtracking and brute force (SR)
Systematically trying possibilities.
Open lesson →3 Object-oriented programming
Classes and objects through tasks in Java: from the first classes to inheritance and interfaces. The order is given in the guide to object-oriented programming examples.
Guide: Object-oriented programming – examples
The order of topics and tips for working.
Open lesson →Classes and objects – basic tasks (SR)
15 tasks with solutions in Java.
Open lesson →Constructors, getters and setters (SR)
Encapsulation and toString through 5 tasks.
Open lesson →An array of objects and ArrayList (SR)
Searching, sorting and ranking lists of objects.
Open lesson →Inheritance and polymorphism (SR)
Abstract classes, interfaces, Comparable.
Open lesson →Additional examples: classes and objects
Picture frames, a group of workers, a car showroom.
Open lesson →4 Checking knowledge: tests
Tests by topic: groups of tasks in PDF, a practice test with solutions and a quiz. The order is given in the guide to tests.
Guide: Tests
All tests in the order of learning and how to use them.
Open lesson →Test: data and formulas (SR)
Integer division, types, formulas.
Open lesson →Test: branching (SR)
if, if–else, switch and checking data.
Open lesson →Test: loops (SR)
for and while, sums, series, simulations.
Open lesson →Test: arrays
The largest and the smallest, the average, a new array.
Open lesson →Test: matrices
Rows, columns, diagonals.
Open lesson →Test: strings (SR)
Characters, words, palindrome, cipher.
Open lesson →Test: functions
Parameters, return value, reference.
Open lesson →Test: classes and objects (SR)
Classes, constructors and methods in Java.
Open lesson →5 More tasks
Once you master the basic examples.
