Search & Find out

Thursday, November 26, 2009

Factorial using functions

 To find factorial of the number 'n' using functions


#include "stdio.h"
#include "conio.h"

void main()
{

      long unsigned int accpt();
      long unsigned int cal();
    void disp();
    clrscr();
    disp();
    getch();
}
long unsigned int accpt()
{
    long unsigned int n;
    printf("Enter a number");
    scanf("%ld", &n);
    return(n);
}
long unsigned int cal()
{
    long unsigned int fact=1, i;
    for(i=accpt(); i>0; i--)
    {
        fact*=i;
    }
    return(fact);
}
void disp()
{
    long unsigned int s=cal();
    printf("The Factorial is %lu", s);
}



Download the executable (.exe)  file for this program..
download

0 comments:

Post a Comment

 

My Blog List

Term of Use