Things You'll Need
Instructions
Open a new plain text file. Some C++ compilers have a dedicated editor. If this is the case, create a new file.
Find the include files that are needed for the program. For this program, two main include files will be needed; "iostream" and "cmath.i". Type the following lines at the top of the new file:
#include <iostream>
#include <cmath>
Type the beginning of the main function, which is where the bulk of the program is placed:
int main()
{
float sinwave [63];
Generate the sine function and place it into an array. To do this, a "for loop" is used that increments a variable between two set number limits. Type the following:
for ( n=0; n<6.28; n=n+0.1)
{
sinwave [n]=sin(n);
}
Save the file and compile it. The array sin(n) will be filled with a sine wave.