Recursive Function in C


Write a program to calculate factorial of a given integer number. Use recursive function

14 comments:

  1. #include
    main()
    {
    int a;
    printf("Enter your number : ");
    scanf("%d",&a);
    fact(a);
    printf("\nFactorial of given integer number :");
    printf("%d\n",fact(a));
    }

    int fact(int p)
    {
    int i;
    int sum=1;
    for (i=1;i<=p;i++)
    {
    sum*=i;
    }
    return sum;
    }

    ReplyDelete
  2. #include
    #include
    long int find_factorial(long int);
    int main()
    {
    int num;
    long int n;
    printf("\n Enter number for find_factorial:");
    scanf("\n%d",&num);
    if(num<0)
    printf("\n Negative number are not allowed");
    else
    {
    n=find_factorial(num);
    printf("\n%d! =%1d",num,n);
    }
    return 0;

    }

    long int find_factorial(long int saad)
    {
    if(saad==0)
    return 1;
    else
    return(saad*find_factorial(saad-1));


    }

    ReplyDelete
  3. #include
    #include
    long int find_factorial(long int shuvo);
    int main()
    {
    long int shohan,salman;
    printf("Enter number for find factorial:");
    scanf("%d",&shohan);
    salman=find_factorial(shohan);
    printf("\n Factorial is %d",salman);
    getch();
    return 0;
    }

    long int find_factorial(long int shuvo)
    {
    if(shuvo==0)
    return 0;
    else if(shuvo==1)
    return 1;
    else
    return(shuvo*find_factorial(shuvo-1));

    }

    ReplyDelete
  4. #include
    #include
    long int find_factorial(long int);
    int main()
    {
    int num;
    long int n;
    printf("\n Enter number for find_factorial:");
    scanf("\n%d",&num);
    if(num<0)
    printf("\n Negative number are not allowed");
    else
    {
    n=find_factorial(num);
    printf("\n%d! =%1d",num,n);
    }
    eturn 0;
    }
    long int find_factorial(long int mennath)
    {
    if(mennath==0)
    return 1;
    else
    return(mennath*find_factorial(mennath-1));
    }

    ReplyDelete
  5. #include
    int fact(int n);
    main()
    {
    int n,result;
    printf("enter the number for find factorial:");
    scanf("%d",&n);
    result=fact(n);
    }
    int fact(int p)
    {
    if(p<=1)
    return(1);
    else
    return(p*fact(p-1));
    }

    ReplyDelete
  6. ID : 201620195
    https://www.dropbox.com/s/zbju2mzftbsdf4v/05.cpp?dl=0

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. MD USUF MIA
    ID 201610456
    https://drive.google.com/open?id=0B_PIGnOMR0K2ek5NenJGV2dtcUk

    ReplyDelete
  9. ID:201520552
    https://drive.google.com/open?id=0B5pG0kIjzgEKVjlxR2Z3M1B4S00

    ReplyDelete
  10. ID:201520552
    2)https://drive.google.com/open?id=0B5pG0kIjzgEKR1d5M2x5VkcwVkk

    ReplyDelete
  11. Summer 2017
    ID#201610042

    https://drive.google.com/file/d/0B99eePh0LV8gLVFndFhVVTVfNWc/view?usp=drivesdk

    ReplyDelete
  12. https://drive.google.com/open?id=0B3bVD5Ppt_STalEwdDJycmVrUW8

    ReplyDelete
  13. https://drive.google.com/open?id=0Byxq3aat_mNSNktYbGJGSS1XaEE

    ReplyDelete
  14. https://drive.google.com/open?id=0B5eevQy6QwSOc3lFSmduYnFoUjQ

    ReplyDelete