answersLogoWhite

0

#include<stdio.h>

#include<conio.h>

int factr(int x);

void main()

{

int a,fact;

printf("\n Enter a value: ");

scanf("%d",&a);

fact=factr(a);

printf("\n Factorial: %d",fact);

getch();

}

int factr(int x)

{

int f,i;

f=1;

for(i=x;i>=1;i--)

f=f*i;

return f;

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

output of a c program using function to find factorial of a number?

In a C program that calculates the factorial of a number using a function, the program typically prompts the user for an integer input. The function then recursively or iteratively computes the factorial by multiplying the number by the factorial of the number minus one until it reaches one. For example, if the user inputs 5, the program outputs 120, as 5! = 5 × 4 × 3 × 2 × 1. The final result is displayed on the screen.


What is a Flow chart for finding factorial of a given number using recursion function?

no answer....pls post


How do you write a program to factorial in PHP?

To write a program that calculates the factorial of a number in PHP, you can use a recursive function or an iterative approach. Here’s a simple example using a loop: function factorial($n) { $result = 1; for ($i = 2; $i &lt;= $n; $i++) { $result *= $i; } return $result; } echo factorial(5); // Outputs: 120 This code defines a function that multiplies numbers from 2 up to the given number $n to compute the factorial.


What is a factorial function in Visual Basic?

' Iterative solution Function iterativeFactorial(ByVal n As Long) As Long Dim factorial As Long = 1 For i As Long = 1 To n factorial *= i Next Return factorial End Function ' Recursive solution Function recursiveFactorial(ByVal n As Long) As Long If n &lt;= 1 Then Return n End If Return n * recursiveFactorial(n - 1) End Function


Factorial of a given numbers in unix using c?

To calculate the factorial of a given number in C on a Unix system, you can use a simple recursive or iterative function. Here's an example of an iterative approach: #include &lt;stdio.h&gt; unsigned long long factorial(int n) { unsigned long long result = 1; for (int i = 1; i &lt;= n; i++) { result *= i; } return result; } int main() { int number; printf(&quot;Enter a positive integer: &quot;); scanf(&quot;%d&quot;, &amp;number); printf(&quot;Factorial of %d is %llu\n&quot;, number, factorial(number)); return 0; } Compile the code using gcc filename.c -o factorial and run it with ./factorial to calculate the factorial of a number.


Factorial of a number in shell?

To calculate the factorial of a number in a shell script, you can use a simple loop. Here's a basic example: #!/bin/bash factorial=1 read -p &quot;Enter a number: &quot; num for (( i=1; i&lt;=num; i++ )) do factorial=$((factorial * i)) done echo &quot;Factorial of $num is $factorial&quot; This script prompts the user for a number, computes its factorial using a for loop, and then prints the result.


What is a fractorial function in visual basic?

In Visual Basic, a factorial function is a mathematical function that calculates the product of all positive integers up to a given number ( n ). It is typically defined using a recursive or iterative approach. For example, the factorial of ( n ) (denoted as ( n! )) can be implemented in code as follows: Function Factorial(n As Integer) As Long If n &lt;= 1 Then Return 1 Else Return n * Factorial(n - 1) End If End Function This function checks if ( n ) is less than or equal to 1 and returns 1; otherwise, it recursively multiplies ( n ) by the factorial of ( n - 1 ).


How do you find factorial of a given number using function in C.?

Use the following function: unsigned fact (const unsigned n) { return n&lt;2 ? 1 : n * fact (n-1); } Note that for a 32-bit unsigned integer, the largest factorial this function can accommodate is 12!


How do you make a programm to find the fectorial by using fuction?

To create a program that calculates the factorial of a number using a function, you can define a recursive function or use an iterative approach. For example, in Python, you can define a function factorial(n) that returns 1 if n is 0 or 1, and calls itself with n-1 otherwise. Alternatively, you can use a loop to multiply the numbers from 1 to n. Here's a simple example using recursion: def factorial(n): if n == 0 or n == 1: return 1 else: return n * factorial(n - 1)


Write a recursive procedure to compute the factorial of a number?

#include &lt;iostream&gt; using namespace std; int main() { int i, number=0, factorial=1; // User input must be an integer number between 1 and 10 while(number&lt;1 number&gt;10) { cout &lt;&lt; "Enter integer number (1-10) = "; cin &gt;&gt; number; } // Calculate the factorial with a FOR loop for(i=1; i&lt;=number; i++) { factorial = factorial*i; } // Output result cout &lt;&lt; "Factorial = " &lt;&lt; factorial &lt;&lt; endl;


Can a factorial Be defined For a negative number?

No, a factorial cannot be defined for negative numbers. The factorial function, denoted as ( n! ), is only defined for non-negative integers, where ( n! = n \times (n-1) \times (n-2) \times \ldots \times 1 ). For negative integers, the factorial is undefined because there is no way to multiply a descending sequence of positive integers that begins from a negative number. The concept of factorial can be extended to non-integer values using the Gamma function, but it remains undefined for negative integers.


What is a recursive function?

A recursive function is one that calls upon itself until a given result in the original call is met. Take a look at this example. Program Recursion; Uses crt; Var number:longint; Function Factorial(number:longint):longint; Begin if number &gt; 0 then factorial:=number*factorial(number-1) else factorial:=1; End; Begin clrscr; readln(number); writeln(factorial(number)); readln; End. Note how the function factorial calls itself.