Actually i am new to this pointer to functions and not able to find out what is the wrong in using the pointer to functions. The code i tried was this:
Code:
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define PI 3.1415926
double y(double);
double cos(double);
void table(double (*f)(),double,double,double);
int main()
{
printf("TABLE OF y(x)= 2*x*x-x+1\n\n");
table(y,0.0,2.0,0.5);
printf("TABLE OF cos(x)\n\n");
table(cos,0.0,PI,0.5);
getch();
return 0;
}
void table(double (*f)(),double min,double max,double step)
{
double a,value;
for(a=min;a<=max;a+=step)
{
value=(*f)();
printf("%5.2f %10.4f\n",a,value);
}
return;
}
double y(double x)
{
return(2*x*x-x+1);
}
I tried in codeblocks compiler but was not able to correct although in turbo C++ it runs by some changes in the code,but not in codeblocks.Please view into it.