I dont know how to use arrays... that is a given... but I am trying. I keep getting errors in my program when I refer to an Array for some reason... mostly with errors like:
error C2040: '<' : 'int [100]' differs in levels of indirection from 'const int'
error C2446: '>' : no conversion from 'const int' to 'int *'
or:
error C2065: 'ave' : undeclared identifier
error C2373: 'ave_bal' : redefinition; different type modifiers
: see declaration of 'ave_bal'
error C2601: 'ave_bal' : local function definitions are illegal
and it is messing up my program so bad I cant even run it at this point. Here is my program... still a HUGE work in progress.
The program is suppsed to take in data entered by the user to figure the average account balance of all balances entered, and then print out a table showing the ID#, that ID's Balance, and the difference from the average that ID is. I know to most of you, this is really easy... but I am a definite n00b and am having a hard time with it. I am down to 14 errors in my program now thoughCode:#include <iostream.h> #include <iomanip.h> //function prototype double ave_bal(int, int); //main function int main () { //variable declarations int n, j; int ID [100] = {0}; int bal [100] = {0}; double ave_bal; double sum_bal; //Loop to input the ID and balance for (n=0; n<=99; n++) { cout<<"Please enter the account ID and account balance, -1 to to stop: "<<endl; cin<<ID<<bal; //Loop to make sure data is within limits if (ID < 1000 || ID > 9999) { cout<<"Invalid ID, please reenter: "<<endl; } if (bal > 10000) { cout<<"Invalid Balance, please reenter: "<<endl; } //display output in table form cout<<"ID Number"<<setw(16)<<"Balance"<<setw(20)<<"Difference from Average"<<endl; for ( ID = 0; ID < n; ID = ID + 1) { cout<<setw(4)<<ID + 1<<setprecision(2) <<setiosflags(ios::fixed | ios::showpoint) <<setw(16)<<bal<<setw(20)<<setprecision(2) <<setiosflags(ios::fixed | ios:: showpoint) <<ave<<endl; } return 0; } //function to determine average balance double ave_bal(int ID [], int num_bal) { double subtotal = 0; double total; for (int j = 0; j< num_bal; j++) { subtotal += ID [j]; } total = subtotal / num_bal; return total; } }
Thanks for any help or pointers you can give me! I definitely need it!!![]()



LinkBack URL
About LinkBacks



