Programming Languages

PROGRAM TO FIND THE FACTORIAL OF A NUMBER USING FUNCTION

/* PROGRAM TO FIND THE FACTORIAL OF A NUMBER USING FUNCTION */

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

int fact(int n);
void main()
{
int n;
clrscr();
printf(“\nENTER THE NUMBER :”);
scanf(“%d”,&n);
fact(n);
printf(“\n FACTORIAL OF N IS : %d”,fact(n));
getch();
}
int fact(int num)
{
int i;
int f=1;
if(num>1)
{
for(i=1;i<=num;i++)
f=f*i;
}
return(f);
}

ANIL VERMA
Hello Everyone, Welcome to A. V. Powertech.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.