All pastes #2112318 Raw Edit

Anonymous

public text v1 · immutable
#2112318 ·published 2012-02-08 05:43 UTC
rendered paste body
#include < stdio.h>
#include <math.h>
#include <stdlib.h>

int factorial (int);

int main (void)
{
	int nVal;
	int fact;

	printf("Enter non-negative integer number you want to find factorial of:\n");
	scanf("%d", &nVal);

	fact = factorial(nVal);

	printf("The factorial of integer entered is %d.\n", fact);

	system ("PAUSE");
	return 0;
}

int factorial (int nVal)
{
	int fact;
	int num = 1;
	
	if (nVal = 0)
		fact = 1;
	else
	{
		while (nVal > num)
		{
			fact = nVal*(nVal-num);
			num++;
		}

	return fact;
}