Peter_APIIT Posted March 22, 2007 Report Share Posted March 22, 2007 I have a math.c file which uses the pow function from math.h but cannot run the project. I don't know what happen. Below is my math.c file: /* program to print a table of powers */ #include <stdio.h> /* this header file includes the pow() function */ #include <math.h> int main() { int num; float rn; printf("Type in a number\n"); 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)); return 0; } Thanks for your help. Your help is greatly appreciated by me and others. Quote Link to comment Share on other sites More sharing options...

## Recommended Posts

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Note:Your post will require moderator approval before it will be visible.