Classroom practice: Pointers
Gábor Horváth / Zsolt Kohári · 2022.10.17.
Function arguments by address. Arrays with functions.
Preparation for the practice:
- The lecture slides on arrays should be reviewed.
- The lecture slides on pointers should be reviewed.
Write a function that receives an integer array, and separates the greater and the smaller than the average elements of the array. The small elements are put into a second array, and the great ones are put into a third array.
Write a function to print the integer array received as a function parameter!
Write a main function that separates the great and small elements of an array and prints them to the screen!
The task is to reverse an array of integers. Let us write two different variants of the solution. According to the first approach, the reversing function receives two arrays, one is the input (the original), and the other is the output (the reversed). The second approach should use only a single array, that contains the input array initially, and the function reverses it in-place, by modifying the content of the input array.
Assume we have a database (an array) of competitors, storing the name, the birth date and the rank.
typedef struct Date { int year, month, day; } Date; typedef struct Competitor { char name[31]; Date birth; int rank; } Competitor;
The task is to write a function that filters the database: the function is given the array of competitors and a target array, where it places the competitors born before 2000 and ranked in the top 100.