11:57 PM 2009-2010 question 6 |
write a program that reads value of x and compute the value of y from the following equation
y = -x + x^2 - x^3 + x^4
#include"stdio.h"
int p(int m, int n);
main()
{
int x, y;
printf("enter x : ");
scanf("%d", &x);
y = -x + p(x,2) - p(x,3) + p(x,4);
printf("Y = %d", y);
getch();
return 0;
}
int p(int m, int n)
{
int i, j=1;
for(i=1;i<=n;i++)
j*=m;
return j;
}
|
|
Total comments: 0 | |