C Program to Find Factorial of a Given Number Using User Defined Function

#include<stdio.h>
#include<conio.h>

/* Function Prototype */
long int fact(int n);

/* Main function */
int main()
{
	 long int number, result;

	 /* Input */
	 printf("Enter any positive integer: ");
	 scanf("%ld", &number);

	 /* Function call */
	 result = fact(number);
	 printf("%ld != %ld",number,result);
	 return(0);
}

long int fact(int n)
{
    long int i, f=1;
    for(i=1;i<= n;i++)
	 {
	  f = f*i;
	 }
	 return f;
}

Output 

Enter any positive integer: 12
12 != 479001600

Leave a Reply

Your email address will not be published. Required fields are marked *

https://atozonlinesolutions.com/wp-content/uploads/2017/03/logo_white.png
https://atozonlinesolutions.com/wp-content/uploads/2017/03/logo_white.png
About
Products
Subscribe

If you wish to receive our latest news in your email box, just subscribe to our newsletter. We won’t spam you, we promise!

    Applauz

    As the pioneer of the lean startup movement, APPLAUZ has dedicated it’s time to sharing effective business strategies that help new businesses and enterpreneurs put their money to work in the right way.

    Subscribe

    If you wish to receive our latest news in your email box, just subscribe to our newsletter. We won’t spam you, we promise!

      Applauz

      As the pioneer of the lean startup movement, APPLAUZ has dedicated it’s time to sharing effective business strategies that help new businesses and enterpreneurs put their money to work in the right way.

      Copyright by BOLD THEMES. All rights reserved.