DAA - Factorial Program ,algorithm and with OUTPUT(BCA- IV sem KSWU)

 Factorial Program


SOURCE CODE :

#include<stdio.h>

#include<conio.h>

#include<time.h>

long int multiplyNumbers(int n);

int main()

{

int n;

clock_t start,end;

double ctu;

clrscr();

start=clock();

printf("\n Enter the positive number: ");

scanf("%d",&n);

printf("\n Factorial of %d is %d",n,multiplyNumbers(n));

end=clock();

ctu=((double)(end-start))/CLOCKS_PER_SEC;

printf("\n Time taken to execute %f sec",ctu);

return 0;

}

long int multiplyNumbers(int n)

{

if (n>=1)

return n*multiplyNumbers(n-1);

else

return 1;

}


OUTPUT : 




No comments:

Post a Comment