WAP using a function “fact()” to calculate factorial of a given number. Take the number as an input from the user.
#include<stdio.h> #include<math.h> int main() { int a,b; printf("Enter the number = "); scanf("%d",&a); b=factorial(a); printf("factorial value of %d is %d ",a,b); } int factorial(int x) { int i,j; j=1; for(i=x;i>=1;i--) { j=i*j; } return j; }
WAP using a function “fact()” to calculate factorial of a given number. Take the number as an input from the user.
Reviewed by Unknown
on
03:35
Rating:
No comments: