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 -
#include <iostream>
-
-
using namespace std;
-
-
int sum(int [], int);
-
int countNmbrsBigger(int [], int, int);
-
int average(int [], int);
-
int high(int [], int);
-
int low(int [], int);
-
int find(int [], int, int);
-
-
-
int main (void ){
-
//test the array class
-
const int arraySize = 10;
-
int theArray[arraySize] = {1, 5, 25, 10, 12, 9, 24, 24, 22, 2};
-
-
cout << "Sum: " << sum(theArray, arraySize) << endl;
-
cout << "Count of numbers bigger than 10: " << countNmbrsBigger(theArray, arraySize, 10) << endl;
-
cout << "Average: " << average(theArray, arraySize) << endl;
-
cout << "High: " << high(theArray, arraySize) << endl;
-
cout << "Low: " << low(theArray, arraySize) << endl;
-
cout << "Find: " << find(theArray, arraySize, 25) << endl;
-
cout << "Find: " << find(theArray, arraySize, 100) << endl;
-
-
}
-
-
-
int sum(int theArray [], int theArraySize){
-
//returns the sum of the values in theArray
-
int sum = 0;
- for (int i = 0; i < arraySize; i++) {
-
[i]sum += anArray;
-
}
-
return sum;
-
}
-
-
int countNmbrsBigger(int theArray [], int theArraySize, int Number){
-
//count the value in the array greater than
-
//the parameter
-
-
}
-
-
int average(int theArray [], int theArraySize){
-
//average the values in the array
-
-
}
-
-
int high(int theArray [], int theArraySize){
-
//find the highest value in the array
-
-
}
-
-
int low(int theArray [], int theArraySize){
-
//find the lowest value in the array
-
int lowValue = theArray[0];
-
for (int i = 0; i < theArraySize; i++){
-
if (theArray[i] < lowValue){
-
lowValue = theArray[i];
-
}
-
}
-
return lowValue;
-
}
-
-
int find(int theArray [], int theArraySize, int theNumber){
-
//return the subscript of the supplied argument
-
//return -1 if not found
-
-
}
4 1817
Because these variableas are visible only within main()
Use parameter names: - for (int i = 0; i <theArraySize ; i++) {
-
sum += theArray[i];
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.
what part of the sentence is it a question
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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
|
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...
|
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...
|
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...
|
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:...
|
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: ...
|
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...
|
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...
|
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,...
|
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$) {
}
...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
| |