Hello There, Guest! Login Register
Advertise Here | Remove Ads

C program to find factorial of a number.

  • 0 Vote(s) - 0 Average


08-14-2016, 08:37 PM #1
Sadness Offline MODERATOR MODERATORS
Posts:4,001 Threads:565 Joined:Sep 2014 Reputation: 13 Sex Female
FFUC: $0
Country: Bangladesh
A simple program to find factorial of a number (integers only)

Code:
/*C program to find factorial of a number.*/

#include <stdio.h>

int main()
{
    int num,i;
    long int fact;
  
    printf("Enter an integer number: ");
    scanf("%d",&num);
  
    /*product of numbers from num to 1*/
    fact=1;
    for(i=num; i>=1; i--)
        fact=fact*i;
        
    printf("\nFactorial of %d is = %ld",num,fact);
      
    return 0;
}

Quote:Output :

Enter an integer number: 5

Factorial of 5 is : 120

[Image: SeoClerks728x90.png]






Forum Jump:


Users browsing this thread:1 Guest(s)

Advertise Here | Remove Ads