[My site ]
Main » 2013 » December » 12 » 2009-2010 question 6
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;
}
Category: C Programming - 1 | Views: 352 | Added by: ahansaary | Rating: 0.0/0
Total comments: 0
Only registered users can add comments.
[ Sign Up | Login ]