This is a program that prompts the user to enter a "n" value and a "k" value, and return how many different ways one can choose a value k from a distinct group n.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int n_choose_k(int n, int k);
int factorial(int m);
int main(int argc, char *argv[]){
int input_n;
int input_k;
printf("Enter your 'n' & 'k' values:");
scanf("%d\n", input_n);
scanf("%d\n", input_k);
printf("nCk = %d", n_choose_k(input_n, input_k));
return 0;
}
int n_choose_k(int n, int k){
int resnCk;
resnCk = factorial(n)/(factorial((n-k))*(factorial(k)));
return resnCk;
}
int factorial(int m){
int result=m;
int i;
for(i=0;i<m;i++){
result *= (result-1);
}
return result;
}
I think your problem is in lines 5 and 7.
First, that's not how you declare a function. Second, you don't need to there, those function are already defined. (lines 27 - 49)
Just erase lines 5 and 7, for reals, and see if it doesn't at least compile then.