I am the developer of some family tree software (written in C++ and Qt). I had no problems until one of my customers mailed me a bug report. The probl
Continue ReadingC++: Black Scholes Call Option Gamma
// Calculate the Black Scholes European call option Gamma double BS_Call_Option_Gamma(double S, double K, double r, double v, double T) // Para
Continue ReadingC++: Function Composition
Create a function, compose, whose two arguments f and g, are both functions with one argument. The result of compose is to be a function of one argume
Continue ReadingC++: Closest-Pair Problem
The aim of this task is to provide a function to find the closest two points among a set of given points in two dimensions, i.e. to solve the Closest
Continue ReadingC++: Include a File
The task is to demonstrate the language's ability to include source code from other files. In C and C++, inclusion of other files is achieved via a
Continue ReadingC++: Multiple Distinct Objects
Create a sequence (array, list, whatever) consisting of n distinct, initialized items of the same type. n should be determined at runtime. By disti
Continue ReadingC++: Anonymous Recursion
While implementing a recursive function, it often happens that we must resort to a separate "helper function" to handle the actual recursion. This
Continue ReadingWhy is processing a sorted array faster than an unsorted array?
Here is a piece of C++ code that seems very peculiar. For some strange reason, sorting the data miraculously makes the code almost six times faster.
Continue ReadingC++: Compile-Time Calculation
Some programming languages allow calculation of values at compile time. For this task, calculate 10! at compile time. Print the result when the progra
Continue ReadingC++: Check That File Exists
In this task, the job is to verify that a file called "input.txt" and the directory called "docs" exist. This should be done twice: once for the curre
Continue Reading