Jump to content
• Advertisement

Public Group

# array + functions

This topic is 4037 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

#include <iostream> #include <iomanip> #include <cmath> #include <cstring> #include <string> using namespace std; void getData (int m[], size int h[], size int 1[]); int averageHigh(int aH[]); int averageLow(int aL[]); int indexHighTemp(int indexH[]); int indexLowTemp (int indexL[] ); int main() { cout << "Kevin's Monthly Tempature/HIGH and LOW"<<endl; string months[12]; int HighTemp[12]; int LowTemp[12]; int i; getData (m[], size h[], size 1[]); return 0; } void getData ( int m[], int h[], int 1[] ); int i; for (int i = 0;int i < 12;int i++); { cout <<" Enter Months" << i + 1 << " : " <<endl; cin>>months; cout<<" Enter Highest Tempature for the month of " << months[0]++ << " : " << endl; cin >> HighTemp ; cout <<" Enter Lowest Tempature for the month of:" <<endl; cin >>LowTemp; } int averageHigh(int twoDim[] [2], int rows) { int i; int sum = 0; for (i = 0; i < rows; i++) sum = sum + twoDim[0]; if (rows > 0) return sum / rows; else return 0; } int averageLow(int twoDim[][2], int rows) { int i; int sum = 0; for (i = 0; i < rows; i++) sum = sum + twoDim[1]; if(rows > 0) return sum /rows; else return 0; } int indexHighTemp(int twoDim[][2], int rows) { int i; int highIndex = 0; for (i = 1; i <rows; i++) if (twoDim[highIndex][0] < twoDim [0]) highIndex = 1; return highIndex; } int indexLowTemp(int twoDim[] [2], int rows) { int i; int LowIndex = 0; for (i = 1; i <rows; i++) if (twoDim[LowIndex] [1] > twoDim [1] ) LowIndex = i ; return LowIndex; } these are my errors 1>------ Build started: Project: TempArray, Configuration: Debug Win32 ------ 1>Compiling... 1>TempArray.cpp 1>c:\users\ben\programming codes\temparray\temparray\temparray.cpp(11) : error C2061: syntax error : identifier 'size' 1>c:\users\ben\programming codes\temparray\temparray\temparray.cpp(24) : error C2144: syntax error : 'int' should be preceded by ')' 1>c:\users\ben\programming codes\temparray\temparray\temparray.cpp(24) : error C2660: 'getData' : function does not take 0 arguments 1>c:\users\ben\programming codes\temparray\temparray\temparray.cpp(24) : error C2059: syntax error : ')' 1>c:\users\ben\programming codes\temparray\temparray\temparray.cpp(27) : error C2143: syntax error : missing ')' before 'constant' 1>c:\users\ben\programming codes\temparray\temparray\temparray.cpp(27) : error C2143: syntax error : missing ';' before 'constant' 1>c:\users\ben\programming codes\temparray\temparray\temparray.cpp(27) : error C2059: syntax error : ')' 1>c:\users\ben\programming codes\temparray\temparray\temparray.cpp(29) : error C2059: syntax error : 'for' 1>c:\users\ben\programming codes\temparray\temparray\temparray.cpp(29) : error C2143: syntax error : missing ')' before ';' 1>c:\users\ben\programming codes\temparray\temparray\temparray.cpp(29) : error C2143: syntax error : missing ';' before '<' 1>c:\users\ben\programming codes\temparray\temparray\temparray.cpp(29) : error C2086: 'int i' : redefinition 1> c:\users\ben\programming codes\temparray\temparray\temparray.cpp(28) : see declaration of 'i' 1>c:\users\ben\programming codes\temparray\temparray\temparray.cpp(29) : error C2143: syntax error : missing ';' before '++' 1>c:\users\ben\programming codes\temparray\temparray\temparray.cpp(29) : error C2086: 'int i' : redefinition 1> c:\users\ben\programming codes\temparray\temparray\temparray.cpp(28) : see declaration of 'i' 1>c:\users\ben\programming codes\temparray\temparray\temparray.cpp(29) : error C2059: syntax error : ')' 1>c:\users\ben\programming codes\temparray\temparray\temparray.cpp(30) : error C2447: '{' : missing function header (old-style formal list?) 1>Build log was saved at "file://c:\Users\Ben\Programming Codes\TempArray\TempArray\Debug\BuildLog.htm" 1>TempArray - 15 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== can someone help me????

#### Share this post

##### Share on other sites
Advertisement
1. Homework? (Not saying it is - just asking :)

2. Place your posted code in [source] tags to preserve formatting. You can edit your post using the 'edit' button in the upper-right.

#### Share this post

##### Share on other sites
Hello,

There is a lot of things that is wrong with the program. I am not going to go through the entire list of your problems, but I will highlight certain ones. First of all, in your main function you call the getData function by passing variables that have not been declared. It should have been this instead: getData(months, HighTemp, LowTemp);. Also, in the getData function your cin parts are wrong. it should be cin>>m; cin>>h; and cin>>l. When you are trying to obtain information in a function and store it in a variable that was passed to it, you have to use the names you declared in the prototype. Therefore, in that example you have to use the m,h, and l and not months, HighTemp, and LowTemp. Also, when you write the contents of the function you do not put a semicolon at the end of the function name. For example:
//this is wrongvoid someFunction (); {//what ever the contents is}//this is correctvoid someFunction(){//what ever the contents is}

There is a lot more stuff wrong in your code. I will advise you to go back on reread on functions and functions with parameters, because you are incorrectly using them. I hope some other people will come and tell you have to fix the rest of your errors, because there is so many that I do not feel like going though all of them.

~Carl J. Loucius

P.S. You should use the source tags. [ source ] [ /source ] without the spaces and put your code in between there.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 12
• 14
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633343
• Total Posts
3011434
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!