Jump to content

Net Beans


Recommended Posts

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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...