I'm having trouble compiling some code for a class....
this is where i'm having trouble
aavg=0; int count=0;
for(int i=0; i<num;i++)
{
if ((math.abs(a[i])<25.0)
{
count++;
aavg+=a[i];
}
}
aavg=aavg/count;
cout << "The average a value in range, absolute value of a is less than 25.0 is: "<< aavg <<endl;
This is my whole program
#include <iostream>
#include <fstream>
#include <math.h>
#include <cmath>
using namespace std;
int main (void)
{
ifstream input ("measurements");
int num=0;
input >> num;
float a[num];
float b[num];
float c[num];
for(int i=0; i<num;i++)
input >> a[i] >> b[i] >> c[i];
//All DATA IN
//Do A AVERAGE
float aavg =0;
for(int i=0; i<num;i++)
aavg+=a[i];
aavg=aavg/num;
cout << "A average: " << aavg <<endl;
//DO SMALLEST B
float smallb=b[0];
for(int i=1; i<num; i++)
if(smallb>b[i])
smallb=b[i];
cout <<"Smallest b: " <<smallb <<endl;
//PRINT ALL GISMO NUMBERS WHERE "a+c<60.0
for(int i=0; i<num;i++)
if((a[i]+c[i])<60.0)
cout <<"Gismo number " <<i <<" has a and c values that total less than 60" <<endl;
//PRINT SMALLEST C VALUE BETWEEN 25.0 AND 50.0
float smallc=51;
for(int i=0; i<num;i++)
if((25.0<c[i])&&(c[i]<50))
if(smallc>c[i])
smallc=c[i];
if(smallc>50)
cout <<"No values in range" <<endl;
else
cout <<"Smallest c in range was: "<<smallc <<endl;
//LAST PART! woot!
aavg=0; int count=0;
for(int i=0; i<num;i++)
{
if ((math.abs(a[i])<25.0)
{
count++;
aavg+=a[i];
}
}
aavg=aavg/count;
cout << "The average a value in range, absolute value of a is less than 25.0 is: "<< aavg <<endl;
//system("PAUSE");
}