fork download
  1. #include <stdio.h>
  2.  
  3. int fact(int z);
  4.  
  5. void main()
  6. {
  7. int n, r, ncr;
  8.  
  9. printf("\n Enter the value for N and R \n");
  10. scanf("%d%d", &n, &r);
  11. ncr = fact(n) / (fact(r) * fact(n - r));
  12. printf("\n The value of ncr is: %d", ncr);
  13. }
  14.  
  15. int fact(int z)
  16. {
  17. int f = 1, i;
  18. if (z == 0)
  19. {
  20. return(f);
  21. }
  22. else
  23. {
  24. for (i = 1; i <= z; i++)
  25. {
  26. f = f * i;
  27. }
  28. }
  29. return(f);
  30. }
Runtime error #stdin #stdout 0s 9432KB
stdin
5
4
stdout
 Enter the value for N and R 

 The value of ncr is: 5