Challenge 1: Halving a Number

In this challenge, we'll create a function which halves the value of a double.

We'll cover the following

Problem Statement

You must write the function halve() which takes in a double pointer and halves the value it points to.

The value should remain half outside the scope of the function as well.

*n = 10;
halve(n);
*n == 5 // The value is halved.

Get hands-on with 1400+ tech skills courses.