Tuesday, 3 April 2012

C program to find Factorial of a positive number

/*Green color shows that its a comment*/
/*Programme to find factorial of a number*/

#include<stdio.h>

int main()
{
          int i , facto=1,num;
        printf("Enter your number\n");
        scanf("%d",&num);
   
          for(i=1;i<=num;i++)//logic to find factorial
          {
              facto=facto*i;
          }

        printf("Factorial of %d is=>%d",num,facto);  //Print output

} //End of main program

No comments:

Post a Comment

Compiler for C,C++ and Python {paste your programme to see the output}