We provide Engineering,HSEB notes, tutorials which can be helpful for students during college life.
Friday, April 10, 2015
14. Write a C program to calculate the factorial of given number using functions.
#include<stdio.h>
#include<conio.h>
void main()
{
int num[10],i;
long int result;
clrscr();
printf("\n Input any 10 numbers:-");
for(i=0;i<10;i++)
{
printf("\n Number [%d]:-",i);
scanf("%d",&num);
if(num<0)
printf("\n Invalid number");
else
{
result=factorial(num[i]);
printf("\n Factorial of %d is %1d", num[i],result);
}
}
getch();
}
long int factorial(int n)
{
int i;
long int fact=1;
if(n==0||n==1)
return(fact);
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment