Kexercise 5.4 Table of reciprocals, squares, cubes, and fourth powers.

Source: Internet
Author: User

Exercise 5-4. Define a two-dimensional array, data[11][5], of type double. Initialize
The elements in the first column has the values from 2.0 to 3.0 inclusive in steps of 0.1.
If the first element in a row have value X, populate the remaining elements in each row
With the values 1/x, X2, X3, and X4. Output the values in the array with each row on a
Separate line and with a heading for each column.

//Exercise 5.4 Table of reciprocals, squares, cubes, and fourth powers.#include <stdio.h>intMainvoid){  Constsize_t nrows = One;//Number of rows in the array  Constsize_t Ncols =5;//Number of columns in the array  DoubleData[nrows][ncols];//Stores Data Values  DoubleValue =2.0; size_t Row=0;//Value to BES stored in arraysize_t col =0 ;  for(row =0; Row < nrows; ++row) {data[row][0] =value; data[row][1] =1.0/data[row][0];//1/xdata[row][2] = data[row][0]*data[row][0];//x*xdata[row][3] = data[row][2]*data[row][0];//x*x*xdata[row][4] = data[row][3]*data[row][0];//x*x*x*xValue + =0.1; } printf ("x"); printf ("1/x"); printf ("x*x"); printf ("x*x*x"); printf ("x*x*x*x");  for(row =0; Row < nrows; ++row) {printf ("\ n");  for(col =0; Col < Ncols; ++col) printf ("%15.4LF", Data[row][col]); } printf ("\ n"); return 0;}

Kexercise 5.4 Table of reciprocals, squares, cubes, and fourth powers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.