Program Statement: In the Mini project second function is to find factorial of a number. Mukesh allotted this function to Shankar.
Help Shankar to write a program to find the factorial of a number using functions.
Function Specification:
int factorial(int n);
Input Format:
Input consists of 1 integer. 
Output Format:
Output consists of a single integer.
Refer sample input and output for formatting details. 
Sample Input:
3
Sample Output:
6


Implementation of above problem:
#include<stdio.h>
int factorial(int);
int main()
{
int number;
//int fact = 1; 
scanf("%d",&number); 
printf("%d",factorial(number));
return 0;
int factorial(int n)
{
int c;
int result = 1;
for( c = 1 ; c <= n ; c++ )
result = result*c;
return ( result );
}



Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: