Monday 30 June 2014

FACTORIAL OF A NUMBER USING C PROGRAM

PROGRAM TO CALCULATE FACTORIAL



#include <stdio.h>

int main()
{ int number,factorial; printf("Enter a number.\n"); scanf("%d",&number); factorial=1; while (number>0){ /* while loop continues until test condition number>0 is true */ factorial=factorial*number; --number; } printf("Factorial=%d",factorial); return 0;
}

No comments:

Post a Comment