Hi , I have to write a program that calculates the number of possible combinations k of n objects.
It has to be a recursive program.
It compiles and runs, but while debugging while I type in some numbers it returns 0 everytime
Thanks for any help
Code:#include <stdio.h> int possibleCombi(int n,int k); int main (void) { int n,k,combinations; printf("type in n , number of total objects"); scanf("%d",&n); printf("type in k , numbers drawn"); scanf("%d",&k); combinations = possibleCombi(n,k); printf("%d",combinations); } int possibleCombi(int n,int k) { if ((k = 0) || (n = k)){ return 1; } if(n > k > 0){ return (possibleCombi(n - 1,k) + possibleCombi(n - 1,k - 1)); } }



LinkBack URL
About LinkBacks


