Why does this bit of code, const float x[16] = { 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1,
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 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 ReadingC++: Insertion Sort
#include <algorithm> template<class Iterator> void insertion_sort( Iterator a, Iterator end ) { std::iter_swap( a, std::min_ele
Continue Reading




