Make a new start with a new Thought!

NOTE :                // indicates comments.This wont get printed in the output.This is used for for documentation purpose. PROGRAM: #inclu...

Factorial of a number (iterative method)

NOTE :
              
// indicates comments.This wont get printed in the output.This is used for for documentation purpose.

PROGRAM:

#include<stdio.h>
#include<conio.h>
void main()
{
 long int n,i;
 int fact=1;
 clrscr();
 printf("Enter a number to find its factorial\t:\t");
 scanf("%ld",&n);                                //ld for long int
 for(i=1;i<=n;i++)
 {
   fact=(fact*i);
 }
 printf("%ld! = %d",n,fact);
 getch();
}

OUTPUT :


0 comments: