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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...