RWalib C Array Library User Guide > Arithmetic Operations > alibProd
  

alibProd
Returns the product of the elements in an array. The PV-WAVE API for this routine is the PRODUCT Function.
Prototypes
wvlong alibProdb( wvlong n, UCHAR *b )
wvlong alibProds( wvlong n, short *b )
wvlong alibProdi( wvlong n, int *b )
wvlong alibProdl( wvlong n, wvlong *b )
double alibProdf( wvlong n, float *b )
double alibProdd( wvlong n, double *b )
COMPLEX alibProdc( wvlong n, COMPLEX *b )
DCOMPLEX alibProdz( wvlong n, DCOMPLEX *b )
Parameters
n — (Input) The number of elements in the source array.
*b — (Input) The n-element source array.
Return value
The product of the elements in array b. Computation is done in the data-type of the return value.
Example
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "alib.h"
void main() {
    /* make up some data for the example */
        UCHAR  b0[5]={1,2,3,4,5};
        wvlong b;
    printf( "\n\n show 5-element vector b0" );
        alibinit( NULL, NULL, NULL, NULL );
        alibPrintArrayb( 1, 1, 1, 5, b0, NULL );
    printf( "\n\n print the product of the elements in b0" );
        b = alibProdb( 5, b0 );
        alibPrintArrayl( 1, 1, 1, 1, &b, NULL );
}
 
Output:
 
 show 5-element vector b0
 
   1   2   3   4   5
 
 print the product of the elements in b0
 
                  120
 

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.