473,387 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

error message

im haveing problems with the following piece of code
in getting an error durring compilling which says
error c2065; 'arraySize' : undeclared identifier line 54
error c2065: 'anArray' : undeclared identifer line 55
(Shown underlined and in Itilacs in the code
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int sum(int [], int);
  6. int countNmbrsBigger(int [], int, int);
  7. int average(int [], int);
  8. int high(int [], int);
  9. int low(int [], int);
  10. int find(int [], int, int);
  11.  
  12.  
  13. int main (void ){
  14. //test the array class
  15.     const int arraySize = 10;
  16.     int theArray[arraySize] = {1, 5, 25, 10, 12, 9, 24, 24, 22, 2}; 
  17.  
  18.     cout << "Sum: " << sum(theArray, arraySize) << endl; 
  19.     cout << "Count of numbers bigger than 10: " << countNmbrsBigger(theArray, arraySize, 10) << endl;
  20.     cout << "Average: " << average(theArray, arraySize) << endl;
  21.     cout << "High: " << high(theArray, arraySize) << endl;
  22.     cout << "Low: " << low(theArray, arraySize) << endl;
  23.     cout << "Find: " << find(theArray, arraySize, 25) << endl;
  24.     cout << "Find: " << find(theArray, arraySize, 100) << endl;
  25.  
  26.  
  27.  
  28. int sum(int theArray [], int theArraySize){
  29. //returns the sum of the values in theArray
  30. int sum = 0;
  31.  for (int i = 0; i < arraySize; i++) {
  32.         [i]sum += anArray;
  33.     }
  34.     return sum;
  35.     }
  36.  
  37. int countNmbrsBigger(int theArray [], int theArraySize, int Number){
  38. //count the value in the array greater than 
  39. //the parameter
  40.  
  41. }
  42.  
  43. int average(int theArray [], int theArraySize){
  44. //average the values in the array
  45.  
  46. }
  47.  
  48. int high(int theArray [], int theArraySize){
  49. //find the highest value in the array
  50.  
  51. }
  52.  
  53. int low(int theArray [], int theArraySize){
  54. //find the lowest value in the array
  55.      int lowValue = theArray[0];
  56.      for (int i = 0; i < theArraySize; i++){
  57.           if (theArray[i] < lowValue){
  58.               lowValue = theArray[i];
  59.           }
  60.      }
  61.      return lowValue;
  62. }
  63.  
  64. int find(int theArray [], int theArraySize, int theNumber){
  65. //return the subscript of the supplied argument
  66. //return -1 if not found
  67.  
  68. }
Jan 18 '09 #1
4 1817
newb16
687 512MB
Because these variableas are visible only within main()
Use parameter names:
Expand|Select|Wrap|Line Numbers
  1.  for (int i = 0; i <theArraySize ; i++) {
  2.    sum += theArray[i];
Jan 18 '09 #2
how do I do this I am new to C++ and am having a hard time with it the code I gave was givne to me to fix errors and these two are the ones that I could not figure out.
Jan 18 '09 #3
newb16
687 512MB
what part of the sentence is it a question
Jan 19 '09 #4
weaknessforcats
9,208 Expert Mod 8TB
The customary approach is to pass the array size as a second argument.

Since both C and C++ pass only the address oif an array and not the array irtself, from the viewpoint of the called function all you have is an address. The fact that that the address is the start of an array has been lost. This is called decay of array. Therefore, always pass the number of elements to your functions.
Jan 19 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: | last post by:
I am accessing the same error-containing ASP page on an ISP server using w2k IE6 but with different effect. On the first computer I get several line of HTML outputed by ASP, shown correctly by...
9
by: Mairhtin O'Feannag | last post by:
Hello, We have two machines we wish to use DPF. They are both RH ES 2.1, with DB2 8.2. I read the documentation CAREFULLY, and added the following line to my db2nodes.cfg file : 1 egret 0
6
by: Squirrel | last post by:
I have a command button on a subform to delete a record. The only statement in the subroutine is: DoCmd.RunCommand acCmdDeleteRecord The subform's recordsource is "select * from tblVisit order...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
10
by: Shawn | last post by:
JIT Debugging failed with the following error: Access is denied. JIT Debugging was initiated by the following account 'PLISKEN\ASPNET' I get this messag in a dialog window when I try to open an...
16
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In:...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.