Factorial

#include<stdio.h>

int main() {

	/* Declaration of Long integer type variables */
	long int no, f = 1;
	printf("Calculate Factorial\n");
	printf("Enter a number:\n");

	/* Received Long integer type number */
	scanf("%ld", &no);
	while(no >= 1) {
		f = no * f;
		no = no - 1;
	}

	/* Print number from a Long integer type variable */
	printf("Factorial: %ld\n", f);
	return 0;
}


/* Output */
Calculate Factorial
Enter a number:
5

Factorial: 120

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!