Table of reciprocals, squares, cubes, and fourth powers : Double « Data Type « C / ANSI-C






Table of reciprocals, squares, cubes, and fourth powers

Table of reciprocals, squares, cubes, and fourth powers
#include <stdio.h>

int main()
{
  double num[11][5];
  double value = 0.0;
  int y = 0;
  int x = 0;


  for(y = 0, value = 3.0 ; y<11 ; y++, value += 0.3)
    num[y][0] = value;

  for(y = 0 ; y<11 ; y++)
  {
    num[y][1] = 1.0/num[y][0];
    num[y][2] = num[y][0]*num[y][0];
    num[y][3] = num[y][0]*num[y][0]*num[y][0];
    num[y][4] = num[y][0]*num[y][0]*num[y][0]*num[y][0];
  }


  printf("\n         x");
  printf("         1/x");
  printf("        x*x");
  printf("         x*x*x");
  printf("      x*x*x*x");

  for(y = 0 ; y<11 ; y++)
  {
    printf("\n");
    for(x = 0 ; x<5 ; x++)
      printf("%15.4lf", num[y][x]);
  }
}

 

           
       








Related examples in the same category

1.A function to output double values in a given widthA function to output double values in a given width
2.Calculating the area of a room
3.Calculating volume price of alternative productsCalculating volume price of alternative products
4.Calculating average hourly pay rateCalculating average hourly pay rate
5.Convert double to int
6.Double calculation: square Double calculation: square