using a 2-dimensional array of doubles : Array Double « Data Type « C / ANSI-C






using a 2-dimensional array of doubles

  
#include <stdio.h>
#include <math.h>

#define iBASES 6
#define iEXPONENTS 3
#define iBASE 0
#define iRAISED_TO 1
#define iRESULT 2

int main( )
{
 double dpowers[iBASES][iEXPONENTS]={
   1.1, 1, 0,
   2.2, 2, 0,
   3.3, 3, 0,
   4.4, 4, 0,
   5.5, 5, 0,
   6.6, 6, 0
 };

 int irow_index;

 for(irow_index=0; irow_index < iBASES; irow_index++)
   dpowers[irow_index][iRESULT] =
     pow(dpowers[irow_index][iBASE],
     dpowers[irow_index][iRAISED_TO]);

 for(irow_index=0; irow_index < iBASES; irow_index++) {
   printf("    %d\n",(int)dpowers[irow_index][iRAISED_TO]);
   printf(" %2.1f = %.2f\n\n",dpowers[irow_index][iBASE],
                              dpowers[irow_index][iRESULT]);
 }

 return(0);
}
  
    
  








Related examples in the same category

1.Summing reciprocals of five valuesSumming reciprocals of five values
2.Summing 100 data values