Friday, December 30, 2011

Factorial using while loop

/*
* Factorial.c

*
* Created on: Dec 30, 2011
* Author: karthikeyan
*/

# include <stdio.h>
# include <conio.h>

int main()
{
int nFact;
int nFactSum=1;
int nLoop;

printf("Enter the factorial numbers\n");

scanf("%d",&nFact);

nLoop = nFact;

while(nLoop > 1)
{
nFactSum = nFactSum * nLoop;

nLoop--;

}

printf("Factorial Value of %d! is :: %d",nFact,nFactSum);



return 0;
}

OUTPUT:

Enter the factorial numbers
5
Factorial Value of 5! is :: 120

No comments:

Post a Comment