Deitel & Deitel, C How to Program 3rd Edition, Exercise 2.31

//Write a program that calculates the squares and cubes of the numbers from 0 to 10 and uses tabs to print the following table of values

#include <stdio.h>

int main() {
int a = 0, b = 1, c = 2, d = 3, e = 4, f = 5, g = 6, h = 7, j = 8, k = 9, l = 10;


printf("number\tsquare\tcube\n");
printf("%d\t%d\t%d\n", a, a*a, a*a*a);
printf("%d\t%d\t%d\n", b, b*b, b*b*b);
printf("%d\t%d\t%d\n", c, c*c, c*c*c);
printf("%d\t%d\t%d\n", d, d*d, d*d*d);
printf("%d\t%d\t%d\n", e, e*e, e*e*e);
printf("%d\t%d\t%d\n", f, f*f, f*f*f);
printf("%d\t%d\t%d\n", g, g*g, g*g*g);
printf("%d\t%d\t%d\n", h, h*h, h*h*h);
printf("%d\t%d\t%d\n", j, j*j, j*j*j);
printf("%d\t%d\t%d\n", k, k*k, k*k*k);
printf("%d\t%d\t%d\n", l, l*l, l*l*l);

return 0;
}

Comments

Popular posts from this blog

Deitel & Deitel, C How to Program 6th Edition, Exercise 6.23 (Turtle Graphics)

Deitel & Deitel, C How to Program 6th Edition, Exercise 6.22 (Total Sales)

Deitel & Deitel, C How to Program 6th Edition, Exercise 5.47 (Craps Game Modification)