Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • A program to find out NCR factor of given number in C language

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 4.75k
    Comment on it

    ncr means : combination in terms of mathematics.We have to find out the perfect combination of given values. In the mathematics nCr has defined as nCr = n! /((n-r)! * r!)

        #include
        int main(){
          int n,r,ncr;
          printf("Enter any two numbers->");
          scanf("%d %d",&n,&r);
          ncr=fact(n)/(fact(r)*fact(n-r));                              //fact denotes factorial of a number .
          printf("The NCR factor of %d and %d is %d",n,r,ncr);
          return 0;
        }
         int fact(int n)                                                    // this is a factorial finding function
        { 
          int i=1;
          while(n!=0){
              i=i*n;
              n--;
          }
          return i;
         }
    
    
      sample output:
        6 4
        The NCR factor of 6 and 4 is 15
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: