Sumana_19

CSED10H1

Apr 22nd, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #define f1(a,b,c) for(a=b;a<=c;a++)
  3. #define f(a,b,c) for(a=b;a<c;a++)
  4. int C(int n,int r);
  5.  
  6. int main(void) {
  7.    
  8.     int n,i,r;
  9.     scanf("%d %d",&n,&r);
  10.    
  11.     printf("Reqd Value is: %d",C(n,r));
  12.    
  13. }
  14.  
  15. int C(int n,int r)
  16. {
  17.     if(r==n)
  18.     return 1;
  19.    
  20.     if(r==0)
  21.     return 1;
  22.    
  23.     if(n<r)
  24.     return 0;
  25.    
  26.     return C(n-1,r)+C(n-1,r-1);
  27.    
  28. }
Add Comment
Please, Sign In to add comment