Monday, June 13, 2016

c program to find factorial of a number without using recursive technique

#include<stdio.h>
#include<conio.h>
void main()
 {
  clrscr();
  int n,m,sum=1,a;
  printf("Enter a no");
  scanf("%d",&n);
//it will loop through the number and multiply all its small integers
  for(int i=1;i<=n;i++)
   {
    sum=sum*i;
   }
  printf("Factorial = %d",sum);
 getch();
}

output
Enter a no 6
720

No comments:

Post a Comment