[ create a new paste ] login | about

Link: http://codepad.org/neq41IRr    [ raw code | output | fork ]

C, pasted on Jun 1:
#include <math.h>
#include <stdio.h>

int main()
{
	double x = 0;
	double y = 0;
	double y_1;
	long i;
	while(1)
	{
		printf("Enter x : ");
		if(!scanf("%lf",&x) || getchar() != '\n')
		{
			while(getchar() != '\n'){}
			printf("bad input\n");
		}
		else
		{
			if((y_1 = x) != 0)
			{
				i = 0;
				do
				{
					y   = y_1;
					y_1 = y + (y - pow(y,4.0)/x)/3;
					printf("Iteration %d\n", (i = i + 1));
					printf("y = %lf\t error = %lf\n", y_1, fabs(y_1 - y));
				}
				while(2*pow(10.0,-6.0) < fabs(y_1 - y));
			}
			printf("answer : %lf\n",y_1);	
		}
	}
	return 0;
}


Output:
1
2
3
In function `main':
undefined reference to `pow'
undefined reference to `pow'


Create a new paste based on this one


Comments: