Search⌘ K

Challenge: Set the Odd Elements in a Dynamic Array to -1

Explore how to modify elements in a dynamic array by writing a function that sets all odd integer values to -1. This lesson guides you through handling pointers, array sizes, and conditions while practicing dynamic memory manipulation in C++.

Problem statement

Your task is to write a function set_odd. In function parameters, we will pass:

  • Pointer arr that will point to an array of type int ...