11.07.2015 Views

tYSR20

tYSR20

tYSR20

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 7: Storing Sequences in Arrays 95In use, valueArray[i] represents the ith element in the array. The indexvariable i must be a counting variable — that is, i must be a char, an int,or a long. If valueArray is an array of ints, valueArray[i] is an int.Using an arrayThe following program inputs a sequence of integer values from the keyboarduntil the user enters a negative number. The program then displays the numbersinput and reports their sum.// ArrayDemo - demonstrate the use of arrays// by reading a sequence of integers// and then displaying them in order#include #include #include using namespace std;// prototype declarationsint sumArray(int integerArray[], int sizeOfloatArray);void displayArray(int integerArray[], int sizeOfloatArray);int main(int nNumberofArgs, char* pszArgs[]){// input the loop countint nAccumulator = 0;cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!