Code compiles okay.
But when I run program after I enter my values as asked,
get segFault. Why ???
I think my scanf and printf lines in main() might be the problem.
Please help.
I want the user to input as
(x,y)
and the result to say
The Coefficients of (x,y) is: (return value)
Any ideas??
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int c(int row, int index);
main()
{
int n, k;
printf("input values of C as (n,k)");
scanf("%d" "%d",n,k);
printf("The coefficient of (%d,%d) is : %d",n,k,c(n,k));
return 0;
}
int c(int row, int index)
{
if (row == 0 || index == 0)
return 1;
else
return c(row-1,index) + c(row-1,index-1);
}