Have a Read!

Hi Everyone.
The idea for this page is to provide new c users simple c tutorials to learn how to develop the logic and more importantly correct way to write syntax.
ENJOY !!!

Saturday, January 29, 2011

C PROGRAM FOR FACTORIAL OF A NUMBER

#include<stdio.h>
int main () {
int i,num,factorial=1;
printf("ENTER THE NUMBER");
scanf("%d",&num);
if(num<0)
printf("Factorial not possible");
else
{
  for (i=1;i<=num;i++)
  {factorial=factorial*i;}
  printf("\nFACTORIAL=%d\n",factorial);      
}
return 0;
}

No comments:

Post a Comment

Related Posts with Thumbnails