answersLogoWhite

0


Best Answer

#include<stdio.h>

const unsigned int rows = 10;

const unsigned int cols = 3;

int table[rows][cols];

int square (const int n) {

return n * n;

}

int cube (const int n) {

return n * n * n;

}

void initialise_table (void) {

int x, y, val;

for (x=0; x<rows; ++x) {

val = x+1;

table[x][0] = val;

table[x][1] = square (val);

table[x][2] = cube (val);

}

}

int main (void) {

int x, y;

initialise_table ();

printf ("Value\tSquare\tCube\n");

for (x=0; x<rows; ++x) {

printf("%d\t%d\t%d\n", table[x][0], table[x][1], table[x][2]);

}

return 0;

}

User Avatar

Ashley Champlin

Lvl 9
1y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a c function to produce a table of the numbers from 1 to their squares and their cubes?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Math & Arithmetic

Squares and cubes from 1to20?

If you include fractions and decimals, then there are an infinite number of squares and cubes in any range. If you consider only whole numbers, then from 1 to 20: Squares: 1, 4, 9, and 16. Cubes: 1 and 8.


Are perfect squares and cubes rational numbers?

Yes. In fact, they are integers.


What numbers are squares and cubes of other numbers?

All non-negative numbers (including zero) are real-number squares of other numbers.All numbers (positive, negative, and zero) are cubes of other numbers."Numbers" generally refers to the set of all real numbers. 2 is the square of a real number, &radic;2. &radic;2 is not a whole number. It's not even rational. But it is a real number, and therefore meets the criteria specified. Even pi (&pi;), an irrational number itself, is the square of another real number (&radic;&pi;). The only real numbers that cannot be squares are negative numbers, because squares of negative numbers are always positive, because the product of two negative numbers is always positive. This restriction, however, does not apply to cubes, because if you multiply three negative numbers by each other, the result is negative.Now, for the question you may have meant to ask: "What numbers are squares and cubes of whole numbers (integers)?"It would be impossible to list all squares and cubes of integers, because even when you limit it to integers, there is still an infinite number of numbers, and every one of them has both a square and a cube.Examples of integers, their squares, and their cubes.0, 0, 01, 1, 1(-1, 1, -1)2, 4, 8,(-2, 4, -8)3, 9, 274, 16, 645, 25, 12510, 100, 1000Only a very few numbers, such as 0, 1, and 64, are both squares and cubes of integers. Note that 64 is 43 and also 82. (see the related question)


What are three numbers less than 1000 that are perfect squares and perfect cubes solution?

Answer: 1, 64, &amp; 729


How are rectangular prisms and cubes different?

Cubes have a square on each side, but rectangular prisms have rectangles or squares.

Related questions

Which numbers have a square and cube root?

Cubes of squares or squares of cubes, like 1, 64 and 729.


Squares and cubes from 1to20?

If you include fractions and decimals, then there are an infinite number of squares and cubes in any range. If you consider only whole numbers, then from 1 to 20: Squares: 1, 4, 9, and 16. Cubes: 1 and 8.


Are perfect squares and cubes rational numbers?

Yes. In fact, they are integers.


Are squares and cubes rational numbers?

Not necessarily. The cube of sqrt(2) is not rational.


The sum of two positive numbers is 4 and the sum fo their cubes is 28 What is the sum of their squares?

The sum of their squares is 10.


How many number of squares are on two cubes?

There are 12 squares on 2 cubes


How are cubes different from squares?

Squares are 2D figures and cubes are 3D figures Also squares are the faces of a cube


What numbers are squares and cubes of other numbers?

All non-negative numbers (including zero) are real-number squares of other numbers.All numbers (positive, negative, and zero) are cubes of other numbers."Numbers" generally refers to the set of all real numbers. 2 is the square of a real number, &radic;2. &radic;2 is not a whole number. It's not even rational. But it is a real number, and therefore meets the criteria specified. Even pi (&pi;), an irrational number itself, is the square of another real number (&radic;&pi;). The only real numbers that cannot be squares are negative numbers, because squares of negative numbers are always positive, because the product of two negative numbers is always positive. This restriction, however, does not apply to cubes, because if you multiply three negative numbers by each other, the result is negative.Now, for the question you may have meant to ask: "What numbers are squares and cubes of whole numbers (integers)?"It would be impossible to list all squares and cubes of integers, because even when you limit it to integers, there is still an infinite number of numbers, and every one of them has both a square and a cube.Examples of integers, their squares, and their cubes.0, 0, 01, 1, 1(-1, 1, -1)2, 4, 8,(-2, 4, -8)3, 9, 274, 16, 645, 25, 12510, 100, 1000Only a very few numbers, such as 0, 1, and 64, are both squares and cubes of integers. Note that 64 is 43 and also 82. (see the related question)


What are three numbers less than 1000 that are perfect squares and perfect cubes solution?

Answer: 1, 64, &amp; 729


What are two consecutive numbers whose cubes produce a sum of 1241?

8 and 9


What natural numbers less than 100 are both perfect squares and perfect cubes?

64 is the square of 8 and the cube of 4.


Are all cubes rectangular prisims and all rectangular prisims are cubes?

This is a little odd, but: All squares are rectangles, but rectangles are never squares.