Wednesday 6 August 2014

C language program to find out the factorial of an integer by using "while" loop.

#include<stdio.h>
main()
{
          double n,ans=1;
          clrscr();
          printf(" Enter a number\n to find factorial of it : ");
          scanf("%lf",&n);
          while (n>1.)
          {
          ans*=n;
          --n;
          }
          printf(" answer = %.2lf",ans);
          getch();

}

No comments:

Post a Comment