title: Number of combinations (N choose R) in C++
body: <p>Here I try to write a program in C++ to find NCR. But I've got a problem in the result. It is not correct. Can you help me find what the mistake is in the program?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int fact(int n){
      if(n==0) return 1;
      if (n&gt;0) return n*fact(n-1);
  };
  
  int NCR(int n,int r){
      if(n==r) return 1;
      if (r==0&amp;&amp;n!=0) return 1;
      else return (n*fact(n-1))/fact(n-1)*fact(n-r);
  };
  
  int main(){
      int n;  //cout&lt;&lt;"Enter A Digit for n";
      cin&gt;&gt;n;
      int r;
           //cout&lt;&lt;"Enter A Digit for r";
      cin&gt;&gt;r;
      int result=NCR(n,r);
      cout&lt;&lt;result;
      return 0;
  }
  </code></pre>