//---------------------------
// lab8.cpp
// Author: Grant Bivens
// Class: EET 2303 C++
// Professor: Dr. Imad Abouzahr
// Date: 4-4-06
// This program generates a table of values at specific times along a sine waveform.
//---------------------------
#include <stdio.h>
#include <stdlib.h>
#include <cmath> // includes
#include <iostream>
#include <iomanip>
using std::cout;
using std::cin; // using standards.
using std::endl;
using std::setw;
const float pi = 3.1415; //set pi as a constant so "pi" can be used instead of 3.141...
// initalize function CalcWaveform
void CalcWaveform ( double Waveform, int size, double frequency, double deltat, double amplitude );
int main() //begin main function
{
int wavesize; // initalize wavesize as integer
double duration, deltat, amplitude, frequency; // initalized as double
cout << "\nEnter duration"; // get duration
cin >> duration;
cout << "\nEnter Delta t"; // get delta t
cin >> deltat;
cout << "\nEnter wave amplitude"; // get amplitude
cin >> amplitude;
cout << "\nEnter wave frequency"; // get frequency
cin >> frequency;
wavesize = static_cast <int> ( duration / deltat ); //set size of wavesize
double Waveform []; // initalize Waveform array
for (int i = 0; i < wavesize; i++) //loop
Waveform [ i ] = 0.0; // initalize array to 0
// call function
CalcWaveform (Waveform , wavesize, frequency, deltat, amplitude);
cout << "\nTime" << setw ( 13 ) << "Sine" << endl; // display header text
// loop to fill waveform array
for ( int h = 0; h < wavesize; h++ )
cout << setw ( 7 ) << h * deltat << setw ( 13 ) << Waveform [ h ] << endl;
system ( "pause" );
return 0;
}
//start CalcWaveform function
void CalcWaveform ( double Waveform, int size, double frequency, double deltat, double amplitude )
{
int i; //initialize i
for ( int i = 0; i < size; i++ ) // counter
Waveform [ i ] = amplitude * sin ( 2 * pi * frequency * i * deltat ); // calculates
cout << Waveform [ i ] << endl; // prints array results
} Usually you should lookin the error line
right before the error line
right after the error line.
In this case it was just before the error line 25. You missed a semicolon.