Tuesday 24 May 2011

Factorial using while Loop

#include<stdio.h>
#include<conio.h>
void main()
{
 long number=1;
 long answer;
 while (number!=0)
 {
  printf("Enter a number: ");
  scanf("%ld",&number);
  answer=1;
  while (number>1)
  answer=answer*numbe--;
  printf("\nFactorial of given No. is %ld",answer);
 }
getch();  


}

0 comments:

Post a Comment