Write a function to compute y XZ5 KD in C programming langua
Write a function to compute y= X!+Z!*5/ K!*D! in C programming language:
Output: Enter X, Z, K and D: 8 6 4 2 result is 915.00
Solution
#include <stdio.h>
int findfact(int n){ /*This program takes input n and returns the factorial of the given n*/
if(n==0) //checking condition for n=0 and returns 1
return 1;
else
return n*findfact(n-1); //it is recurssion recurssively calling the function
}
int main()
{
int x,z,k,d;
int a,b,c,e;
int y;
printf(\"Enter x,z,k,d values:\");
scanf(\"%d %d %d %d\",&x,&z,&k,&d); //prompting the user to enter x,y,z,d values
a=findfact(x); //finding the factiorial of x
b=findfact(z); //finding the factiorial of z
c=findfact(k); //finding the factiorial of k
e=findfact(d); //finding the factiorial of d
y=(a+b*5/c*e); //assigning given equation to variable y
printf(\"result is %d\",y); //printing the result
}
