by Dinesh Thakur

In this program user ask to find out the Power of numeric value as cubic, trigonometric etc. to print the table of powers user need to declare all the power functions. In first instance user declare math.h header file this file contains all the power () functions. User declares integer type and float type variables for process to print the power tables. User asks to enter the value for printing the power table. After declare the value user put the method to find the powers of value like cubic, quadric etc. user in the end print the value through the printing method.

**Problem Statement:**

This Is C program that asks user to print a table for Power functions.

- Declare the variables.
- Using printing method.
- Display output as result on the screen.

Here is C source code for printing the table of powers. Output of this program shown below.

#include <stdio.h>

/* this header file includes the pow() function */

#include <math.h>

int main()

{

int num;

float rn;

clrscr();

printf("Type in a Number : ");

scanf ("%d",&num);

printf("\nHere is a table for the square\n");

printf("cube, quartic and quintic for %d to %d:\n\n", num, num+4);

printf("Integer\tSquare\tCube\tQuartic\tQuintic\n"); /* if read in as int must be converted to float for pow() */

rn=num;

/* each specifier includes the same width as header, no decimal places with following tab*/

printf("%7.0f\t%6.0f\t%4.0f\t%7.0f\t%7.0f\n", rn,pow(rn,2),pow(rn,3),pow(rn,4),pow(rn,5)); rn++;

printf("%7.0f\t%6.0f\t%4.0f\t%7.0f\t%7.0f\n", rn,pow(rn,2),pow(rn,3),pow(rn,4),pow(rn,5)); rn++;

printf("%7.0f\t%6.0f\t%4.0f\t%7.0f\t%7.0f\n", rn,pow(rn,2),pow(rn,3),pow(rn,4),pow(rn,5)); rn++;

printf("%7.0f\t%6.0f\t%4.0f\t%7.0f\t%7.0f\n", rn,pow(rn,2),pow(rn,3),pow(rn,4),pow(rn,5)); rn++;

printf("%7.0f\t%6.0f\t%4.0f\t%7.0f\t%7.0f\n", rn,pow(rn,2),pow(rn,3),pow(rn,4),pow(rn,5));

getch();

return 0;

}

Dinesh Thakur is a Technology Columinist and founder of Computer Notes and Technology Motivation.
Turn Mobile View Off