answersLogoWhite

0

/*program for finding the factorial*/

void main()

{

int a,b=1;

clrscr();

printf("Please enter any number to find its factorial\n");

scanf("%d",&a);

while(a>1)

{

b=b*a;

a--;

}

printf("factorial is %d",b);

getch();

}

User Avatar

Wiki User

11y ago

What else can I help you with?

Continue Learning about Engineering

Write the Pseudocode to find the factorial of a number?

Pseudo code+factorial


Using while loop Write a program find the factors of a number?

by this program you can find the factorial: #include<iostream> using namespace std; main() { int n,x,f=1; cin>> n; x=0; while(x<n) { x++; f= f*x; } cout<<"factorial is"<<f<<"\n"; system("pause"); return 0; }


How to write a program to find the delimiter matching in stacks?

== == using recursions: unsigned int Factorial( unsigned int x) { if(x>0) { return ( x * Factorial(x-1)); } else { return(1); } } factorial: unsigned int Factorial( unsigned int x) { unsigned int u32fact = 1; if( x == 0) { return(1); } else { while(x>0) { u32fact = u32fact *x; x--; } } }


How do you write a C program to calculate the factorial within recursive function?

// Iterative solution unsigned long iterativeFactorial(const unsigned long n) { unsigned long i, factorial = 1; for(i = 1; i <= n; i++) { factorial *= i; } return factorial; } // Recursive solution unsigned long recursiveFactorial(const unsigned long n) { if(n <= 1) { return n; } return n * recursiveFactorial(n - 1); } // Sample calls int main() { unsigned long n; printf("Enter a number to find its factorial: "); scanf("%u",&n); printf("Iterative factorial: %u\n", iterativeFactorial(n)); printf("Recursive factorial: %u\n", recursiveFactorial(n)); return 0; }


What is simulation recursion in C?

The factorial f(n) = n * (n-1) * (n-2) * .. 1. For example factorial 5 (written as 5!) = 5 x 4 x 3 x 2 x 1 = 120. The function below returns the factorial of the parameter n. int factorial( int n) { if (n==1) return 1 else return n* factorial( n-1) ; }

Related Questions

Jntu 2-2 oops through java answers?

write a java program to find factorial using recursive and non recursive


Which is faster to find factorial whether recursive or dowhile?

recursion is always slower than iteration


Write a c program to find GCD of two given integers by using both recursive n non recursive functions?

i love u darling


Write the Pseudocode to find the factorial of a number?

Pseudo code+factorial


Write a c program to find the factorial of 125?

int main (void) { puts ("18826771768889260997437677024916008575954036487149242588759823150835\ 31563316135988668829328894959231336464054459300577406301619193413805\ 97818883457558547055524326375565007131770880000000000000000000000000\ 000000"); return 0; }


Implement a program to find out the reverse of an integer using recursive functions?

Note: You may need a larger data type, factorials become very big very quickly and may cause an overflow long factorial(int x) { if(x == 1) return 1; . return((long) factorial(x-1) * x);


C program to find factorial of a no?

this is a code for calculating it recursivelly: float Factorial (float n) { if (n<=1) return 1.0; else return n* Factorial(n-1); }


Using while loop Write a program find the factors of a number?

by this program you can find the factorial: #include<iostream> using namespace std; main() { int n,x,f=1; cin>> n; x=0; while(x<n) { x++; f= f*x; } cout<<"factorial is"<<f<<"\n"; system("pause"); return 0; }


Write a program in java to find factorial of a number?

I suggest to use a for loop, more or less like this (assuming the parameter is "n"): product = 1; for (int i = 1; i <= n; i++) { product *= i; }


Write a sell program to find the factorial of a number?

#file.sh#run as sh file.shecho "Enter the no."read ni=nr=1while [ $i -ge 1 ]dor=`expr $r \* $i`i=`expr $i-1`doneecho Factorial is $rIf the ans helps you,plz increase the trust point.


How to write a program to find the delimiter matching in stacks?

== == using recursions: unsigned int Factorial( unsigned int x) { if(x>0) { return ( x * Factorial(x-1)); } else { return(1); } } factorial: unsigned int Factorial( unsigned int x) { unsigned int u32fact = 1; if( x == 0) { return(1); } else { while(x>0) { u32fact = u32fact *x; x--; } } }


How do you write a C program to calculate the factorial within recursive function?

// Iterative solution unsigned long iterativeFactorial(const unsigned long n) { unsigned long i, factorial = 1; for(i = 1; i <= n; i++) { factorial *= i; } return factorial; } // Recursive solution unsigned long recursiveFactorial(const unsigned long n) { if(n <= 1) { return n; } return n * recursiveFactorial(n - 1); } // Sample calls int main() { unsigned long n; printf("Enter a number to find its factorial: "); scanf("%u",&n); printf("Iterative factorial: %u\n", iterativeFactorial(n)); printf("Recursive factorial: %u\n", recursiveFactorial(n)); return 0; }