473,473 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

error message

2 New Member
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 1820
newb16
687 Contributor
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
yohanus
2 New Member
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 Contributor
what part of the sentence is it a question
Jan 19 '09 #4
weaknessforcats
9,208 Recognized Expert Moderator Expert
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.