Sunday, March 12, 2017

Square and Cube Number in C

In this article I would like to share with you a program that uses for loop statement in  C to generate square and cube number values in C. The code is very simple and easy to understand. I am using CodeBlocks as my text editor and Dev C++ as my C and C++ compiler.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing


#include <stdio.h>

int num_value=0;

int main()

{
    printf("\t  SQUARE AND CUBE NUMBER IN C");
    printf("\n\n");
    printf("NUMBER     SQUARE      CUBE\n");
    printf("======     ======      ===== ");
    printf("\n\n");
     for (num_value=1; num_value<=12; num_value++)
     {
         printf("%3d       %4d       %6d\n",num_value,num_value*num_value,num_value*num_value*num_value);
     }
    printf("\n\n");
    printf("\t End of Program ");
    printf("\n\n");
}

No comments:

Post a Comment