I am having a problem with my code. below i have outlined the home work requirement. please take a look at the second part(this is the code that i have written) I keep getting an error when i try to run the code.
The error states:The program '[3716] Lab02 Case01.exe: Native' has exited with code 0 (0x0).

Objective: Create a C++ console application that can analyze numeric data contained in an single-dimension array of type integer.

Steps:

Create a new Visual Studio project and source code file.
Copy and paste the code below into a source code file.
Add the following functions to your program:
Sum – return a sum of all of the data in the array
CountNmbrsBigger – return a count of the number of data elements in the array that are larger than a given integer
Average – returns an average of the data in an array
High – returns the highest value in the array
Low –returns the lowest value in the array
Find(number) – returns the first index of the location of the number in the array
Test your class by creating a main function and an array with 10 numbers, invoking each function and displaying the results to the screen.
Use the following prototype definition in the creation of your functions:

/******************************************************************
* Programmer: [put your name here]
*
* Date: [put the current date here]
*
* Course: COMP 220
*
* Assignment: Searching & Summarizing Array Data
*
* File name: XXX.cpp [put your initials instead of XXX]
*
* Description: This program contains functions to perform
* basic search and summary operations on a single-dimension array
*  
* Assumptions: none
* 
* Input: none 
* 
* Output: screen - display the result of each function to the screen 
* 
********************************************************************/ 

#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 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

}

 HERE is my code.  It builds with no errors but when i try to run it i get the error stated above.

#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 total=0;
	for(int i=0;i<theArraySize;i++)
	{
		total += theArray[i];
	}
	return total;
}

int countNmbrsBigger(int theArray [], int theArraySize, int Number)
{
//count the value in the array greater than
//the parameter 
	int count=0;
	for(int i=0;i<theArraySize;i++)
	{
		if(theArray[i]>Number)
		{
			count++;
		}
	}
	return count;
}

int average(int theArray [], int theArraySize)
{
//average the values in the array 
	int sum=0,avg;
	for(int i=0;i < theArraySize;i++)
	{
		sum += theArray[i];
	}
	avg = sum / theArraySize;
	return avg;
}

int high(int theArray [], int theArraySize)
{
//find the highest value in the array 
	int highValue = theArray[0];
	for(int i=0;i<theArraySize;i++)
	{
		if(theArray[i] > highValue)
		{
			highValue = theArray[i];
		}
	}
	return highValue;
}

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 
	int index=-1;
	for(int i=0;i<theArraySize;i++)
	{
		if(theNumber == theArray[i])
		{
			index = i;
		}
	}
	return index;
}

Any suggestions would be great.

Recommended Answers

All 5 Replies

Add cout's at key points in the code to pinpoint where the problem is.

Add cout's at key points in the code to pinpoint where the problem is.

Walt,
I am new at this, cout's in the each section, not all at the beggining?

I need to remeber to scroll up: Here are what the errors are defined as:
'Lab02 Case01.exe': Loaded 'C:\Documents and Settings\wv228c\Desktop\Devry\Comp 220\Lab02 Case01\Release\Lab02 Case01.exe', Symbols loaded.
'Lab02 Case01.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Cannot find or open the PDB file
'Lab02 Case01.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', Cannot find or open the PDB file
'Lab02 Case01.exe': Loaded 'C:\WINDOWS\system32\msvcp100.dll', Symbols loaded.
'Lab02 Case01.exe': Loaded 'C:\WINDOWS\system32\msvcr100.dll', Symbols loaded.

> The error states:The program '[3716] Lab02 Case01.exe: Native' has exited with code 0 (0x0).
This means your program exited successfully (ie, it didn't crash).
Whether it did what you want is another matter, but at least it compiles and runs.

> 'Lab02 Case01.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Cannot find or open the PDB file
> 'Lab02 Case01.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', Cannot find or open the PDB file
These are just warning you that IF you wanted to debug right down into the kernel, that you would have a hard time.
As a newbie, it's not something you'll be doing any time soon, so it's not worth worrying about.
It doesn't affect your program's ability to run.

Add cout's at key points in the code to pinpoint where the problem is.

Walt,
I am new at this, cout's in the each section, not all at the beggining?

If you put all the cout's at the beginning, how would that pinpoint there the problem is?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.