Monday, 6 May 2013

FACTORIAL CALCULATION WITHOUT ANY FUNCTION

Here I have a C program to calculate the factorial of a number without any function call.
Most of the factorial calculating programs involve a recursive call, and what if you don't want any recursive call. In that case my program is here to solve your problem. It's a very simple program and can be easily understood. Hope this program is helpful for you.

SOURCE CODE :-
/*****************************************************************************/

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

int main()
{
int i,num;
long factorial=1;

printf("ENTER THE NUMBER : ");
scanf("%d",&num);

for(i=0;i<num;i++)
{
factorial*=(i+1);
}

printf("FACTORIAL = %ld",factorial);
getch();
return 1;
}

/*******************************************************************************/

Other links for reference :-

No comments:

Post a Comment