Statistics Functions: |
|
Extended __fastcall Sum(const double * Data, const int Data_Size);
The Sum() function is used to calculate the sum value of a group of numbers. The first argument of this function, Data, is the name of an array that holds the numbers considered. The Data_Size argument is the dimension of the array minus 1. To get the sum of a group of numbers, declare an array to hold the necessary numbers. The numbers can be integers or double precision values. You can initialize the array with these numbers or request their values from the user. Here is an example of calculating a total number of grades of a student: |
//--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { Double Grades[] = { 12.50, 14.00, 16.00, 15.50, 12.00, 10.50, 14.50, 17.50 }; int Size = (sizeof(Grades)/sizeof(double)) - 1; Double Total = Sum(Grades, Size); Edit1->Text = FloatToStr(Total); } //---------------------------------------------------------------------------
Home | Copyright © 2004-2016, FunctionX, Inc. | |