Friday 28 June 2013

Write a C program to find the value of nPr, n and r are taken from the keyboard




#include <stdio.h>
main()
{
    int n,r;
    float f;
    printf("Enter the values of N and R:\n");
    scanf("%d%d",&n,&r);
    f=fact(n)/fact(n-r);
    printf("nPr values is : %5.2f",f);
    getch();
}
fact(int n)
{
    int i,f=1;
    for (i=1; i<=n; i++)
        f=f*i;
    return(f);
}

2 comments:

  1. can you give this solve without using function plzz.....

    ReplyDelete
  2. The code doesn't work properly

    ReplyDelete