jituTechnology

jituTechnology

A program to calculate the factorial of a given number using function.

A program to calculate the factorial of a given number using function.

Codes
/*A program to calculate the factorial of a given number using function*/
/*Programed by          Jitendra Kr Yadav
                        10116
                        22 Mar,2011*/
#include<stdio.h>
#include<conio.h>
int factorial(int);
main()
{
int x, y;
printf(“Enter a number: “);
scanf(“%d”,&x);
y=factorial(x);
printf(“Factorial= %d\n\n”,y);
printf(“Press any key to continue…”);
getch();
}
int factorial(int x)
{
int i, fact=1;
if((x==1)||(x==0))
{
return(1);
}
else
{
for(i=1;i<=x;i++)
fact=fact*i;
return(fact);
}
}
Output
Enter a number: 5
Factorial = 120
Press any key to continue…
Add a comment

Comments (1)

  1. Loraine DebrechtApril 5, 2012 Reply
    Hello Dear, are you genuinely visiting this website daily, if so after that you will without doubt obtain fastidious experience.

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

September 2020
S M T W T F S
« Jun    
 12345
6789101112
13141516171819
20212223242526
27282930