#include #include //for setw and setprecision #include #include //for pow using namespace std; //Set of organ pipes spanning one octave. //Each pipe (except the first) is factor times as long as the previous one. // //Mathematicl note: the value that I put into the variable factor is a special //number. If you mutiply this number times itself 12 times, the product will //be 2. Thus //factor * factor * factor * factor factor * factor * factor * factor //* factor * factor * factor * factor is equal to 2. //The last pipe in this set of 13 pipes should therefore be twice as long as the//first pipe, making a tone that is one octave deeper than that of the first //pipe. int main() { double factor {pow(2.0, 1.0/12.0)}; //twelfth root of 2 cout << "Each pipe is " << fixed << setprecision(3) << factor << " times as long as the previous one.\n\n"; double length {100.0}; //length of each pipe for (int pipe {0}; pipe <= 12; ++pipe) { cout << setw(2) << pipe << " " << fixed << setprecision(3) << length << "\n"; length *= factor; //means length = length * factor; } return EXIT_SUCCESS; }