in turboc++
-----------------------------------------------------------------------------
//program to get factorial value of a number using function.use no arguments and return some value
#include<stdio.h> //header file
#include<conio.h>
int factorial(); // function prototype/declaration with return type int.
int main() //main function
{
printf("factorial value=%d",factorial()); // function calling with value.
return 0; //returns 0 value
}
int factorial() // function body line ; also called function definition
{
int factorial_value=1,i; //initialization to value 1
int n; // variable declaration
printf("enter a number\n");
scanf("%d",&n); //input
for(i=1;i<=n;i++) //loop running from 1 to 100 with increment 1 each time
{
factorial_value=factorial_value*i; //formulation for factorial
}
return factorial_value; // returning output of function
}
------------------------------------------------------------------------------------------------------
in codeblocks:
-------------------------------------------------------------------------------------------------------
//program to get factorial value of a number using function.use no arguments and return some value
#include<stdio.h> //header file
int factorial(); // function prototype/declaration with return type int.
int main() //main function
{
printf("factorial value=%d",factorial()); // function calling with value.
getch();
return 0; //returns 0 value
}
int factorial() // function body line ; also called function definition
{
int factorial_value=1,i; //initialization to value 1
int n; // variable declaration
printf("enter a number\n");
scanf("%d",&n); //input
for(i=1;i<=n;i++) //loop running from 1 to 100 with increment 1 each time
{
factorial_value=factorial_value*i; //formulation for factorial
}
return factorial_value; // returning output of function
}
-----------------------------------------------------------------------------
//program to get factorial value of a number using function.use no arguments and return some value
#include<stdio.h> //header file
#include<conio.h>
int factorial(); // function prototype/declaration with return type int.
int main() //main function
{
printf("factorial value=%d",factorial()); // function calling with value.
return 0; //returns 0 value
}
int factorial() // function body line ; also called function definition
{
int factorial_value=1,i; //initialization to value 1
int n; // variable declaration
printf("enter a number\n");
scanf("%d",&n); //input
for(i=1;i<=n;i++) //loop running from 1 to 100 with increment 1 each time
{
factorial_value=factorial_value*i; //formulation for factorial
}
return factorial_value; // returning output of function
}
------------------------------------------------------------------------------------------------------
in codeblocks:
-------------------------------------------------------------------------------------------------------
//program to get factorial value of a number using function.use no arguments and return some value
#include<stdio.h> //header file
int factorial(); // function prototype/declaration with return type int.
int main() //main function
{
printf("factorial value=%d",factorial()); // function calling with value.
getch();
return 0; //returns 0 value
}
int factorial() // function body line ; also called function definition
{
int factorial_value=1,i; //initialization to value 1
int n; // variable declaration
printf("enter a number\n");
scanf("%d",&n); //input
for(i=1;i<=n;i++) //loop running from 1 to 100 with increment 1 each time
{
factorial_value=factorial_value*i; //formulation for factorial
}
return factorial_value; // returning output of function
}
No comments:
Post a Comment