Question: /*Calculate Binomial coefficient */ #include //Function to find the Binomial coefficient int binomial_coefficient (int n, int m) { int bio; //to store the result and
/*Calculate Binomial coefficient */
#include
//Function to find the Binomial coefficient int binomial_coefficient (int n, int m) {
int bio; //to store the result and return to main function //calculation of binomial coefficient bio = factorial (n) + (factorial (m) * factorial (n - m));
return bio; }
//Function to find the factorial of given number and return to function call int factorial (int f) { int fact = 1; int i;
for (i = 1; i <= f; i++) fact = fact * i; //Calulate factorial
return fact; }
void AdjustArray (int arr[], int size) { int i;
for (i = 0; i < size; i++) { // Will be an odd number if (i % 2 == 1) arr[i] = -arr[i]; // Will be an even number if (i % 2 == 0) arr[i] = 0; }
return; }
int main () { int m, n; int bio;
do //making sure n > m { printf ("Enter value for n & m (n > m) : "); scanf ("%d%d", &n, &m); //n amd m values } while (n < m);
bio = binomial coefficient (n, m); //Calling of function and stored the return value in bio variable printf("Binomial Coefficient of %d and %d is %d ", n, m, bio);
unsigned int i; //initialize variable i
int arr[] = { 1, 11, 188, 334, 92, -8, 7, -7, -7777777 }; int size = 9; AdjustArray (arr, size);
for (int i = 0; i < size; i++) { printf ("%d ", arr[i]); }
return 0; }
I keep getting an error for my binomial coefficient and i'm not really sure why?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
