This is a simple demonstration of how to use SDL to create an application that generates sound, in particular a sinusoidal tone. you can play around with the frequency, volume, as well as the function used for the tone generation. Can you generate a square wave or a sawtooth wave?
Compile and link with SDL, e.g.:
g++ -Wall -O3 -o main -lSDL2 main.cpp