Saturday, 7 July 2012

c program find factorial number using function

For beginners
{I am going write the c program but before you need a c compiler.there are a lot of compilers. like dev c++  Download Code::Blocks, dev c++ its free and install it in your computer.open  dev c++ go to file-->new-->source file.} 


#include<stdio.h>
#include<conio.h>
long fa(int);
main()
{
      int num;
      printf("enter number\n");
      scanf("%d",&num);
      printf("factorial of %d = %d",num,fa(num));
      getch();
      return 0;
      }
      long fa(int n)
      {
           int c;
           long fact;
           fact=1;
           for(c=1;c<=n;c++)
           fact=fact*c;
           return fact;
           }


For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}

IS IT HELPFIL? comment.

No comments:

Post a Comment