0:15 AM 2007-2008 question 3 |
write program calculate
z = x^y(x!+y!)/(x!-y!)
#include"stdio.h"
float factorial(float k);
float power(float m, float n);
main()
{
float x, y, z;
printf("enter x : ");
scanf("%f", &x);
printf("enter y : ");
scanf("%f", &y);
z = power(x,y)*(factorial(x)+factorial(y))/(factorial(x)-factorial(y));
printf("Z = %.2f", z);
getch();
return 0;
}
float factorial(float k)
{
int i, fact=1;
for(i=1;i<=k;i++)
fact*=i;
return fact;
}
float power(float m, float n)
{
int i, p=1;
for(i=1;i<=n;i++)
p*=m;
return p;
}
|
|
Total comments: 0 | |