Sunday, September 4, 2016

// // Leave a Comment

Table Of Squares And Cubes In C

Question: Using only the techniques you learned in this chapter, 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:
Table of squares and cubes
/* 
 * Author: AGHATISE OSAZUWA
 * Website: www.cscprogrammingtutorials.com
 *
 * Program to calculate the squares and square roots of numbers from 0 to 10.
 *
 */

#include <stdio.h>
int main ( ){ 
    printf("number\tsquare\tcube\n");
    printf("%d\t%d\t%d\n", 0, 0*0, 0*0*0);
    printf("%d\t%d\t%d\n", 1, 1*1, 1*1*1);
    printf("%d\t%d\t%d\n", 2, 2*2, 2*2*2);
    printf("%d\t%d\t%d\n", 3, 3*3, 3*3*3);
    printf("%d\t%d\t%d\n", 4, 4*4, 4*4*4);
    printf("%d\t%d\t%d\n", 5, 5*5, 5*5*5);
    printf("%d\t%d\t%d\n", 6, 6*6, 6*6*6);
    printf("%d\t%d\t%d\n", 7, 7*7, 7*7*7);
    printf("%d\t%d\t%d\n", 8, 8*8, 8*8*8);
    printf("%d\t%d\t%d\n", 9, 9*9, 9*9*9);
    printf("%d\t%d\t%d\n", 10, 10*10, 10*10*10);
    return 0;
}
Click here to see other solutions to Deitel C How To Program exercises.

0 comments:

Post a Comment


DISCLAIMER: Opinions expressed in comments are those of the comment writers alone and does not reflect or represent the views of the post author. We reserve the right to delete any post deemed inappropriate or offensive and/or spammy. Please do not use abusive words/hate speech.

I Appreciate your valuable Feedback. So, Please DO NOT SPAM - Spam comments will be deleted immediately.

Don't use brand name in name field and you're not allowed to use links in comments unless it's necessary. Such comments will be removed immediately.

Thanks.