Hello, I am a beginner.I am getting 2 errors.Please help to solve them.
The program first takes the readings ..then gives the average .After that it subtracts the average of the readings with the readings and then finally gives that out.
The error is in the 39th and 47th line .It is :
Error :invalid types 'Double[int]' for array subscript
#include <iostream>
#include <cmath>
usingnamespace std;
int main()
{
double r[11];
double ravg;
double sum = 0;
int i;
double dravg;
double drsum = 0;
double dr;
cout << "Enter the readings :\n" << endl;
for(i = 0; i < 10 ; i ++)
{
cin >> r[i]; // 1. lets the user enter readings.
}
for(i = 0; i < 10; i++)
{
sum = (sum + r[i]); // 2. for the average of the readings.
}
ravg = sum /10;
cout << "The average of the readings is " << ravg << endl;
cout << " ....\a\a\a\a\n";
cin.get();
for(i = 0; i<10; i++)
{
abs(dravg[i]) = ravg - r[i]; // Line 39
//3.(the average of the readings) - every reading = dr
}
for(i = 0; i < 10 ; i++)
{
drsum = drsum + dravg[i]; // average of dr see comment no.3 ( line 47)
}
dravg = drsum /10;
cout << " The dravg = " << dravg << endl; //outputs dravg.
cin.get();
return 0;
}
Thank You.
Also there is code tags (looks like <> on right of post creating/editing field)
If you edit your post and include your code inside code tags, ut would be easier to read.