Wednesday, 31 July 2019

How to write a program to find the factorial of a given number?

#include<stdio.h>
#include<conio.h>
void main()
{
  int i, fact=1, num;
  printf("Enter the number/n");
  scanf("%d", &num);
    if(num=0)
           fact=1
    else
        {
            for(i=1;i<=num;i++)
     {
         fact*i
}
}
   printf("factorial of number%d=%5 d/n",num, fact);
getch();
}

No comments:

Post a Comment