answersLogoWhite

0

Find factorial at given number using do while loop?

Updated: 8/20/2019
User Avatar

Wiki User

11y ago

Best Answer

Actually, a for loop is more appropriate in this case. With while, it would be something like the following pseudocode - adapt to your favorite programming language:

function factorial(n)

result = 1

factor = 1

while factor <= n

{

result *= factor

factor++

}

return result

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Find factorial at given number using do while loop?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Programming to calculate a factorial number?

double factorial(double N){double total = 1;while (N > 1){total *= N;N--;}return total; // We are returning the value in variable title total//return factorial;}int main(){double myNumber = 0;cout > myNumber;cout


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;


Program to find n th fabonacci number?

#include #include using std::cin;using std::cout;using std::endl;using std::tolower;long factorial(const int& N);int main(){int N = 0; //factorial of Nchar command = 'n';do{cout > N;cout


How do you write a program to compute and print the factorial of given number using a while loop in c plus plus?

// returns n! int fact(final int n) { // keep track of factorial calculation in f // f starts at n, and we will multiply it by all integers less than n int f = n; // loop from n-1 down to 2 for(int i = (n - 1); i &gt; 1; --i) { // increase our total product f *= i; } return f; }


Program in c to generate table of factorials?

#include #include using std::cin;using std::cout;using std::endl;using std::tolower;long factorial(int N);int main(){int N = 0; //factorial of Nchar command = 'n';do{cout > N;cout


Write the program that display the factorial of a number?

/* gcc -ansi -Wall -Wextra -pedantic -s -static 0.c -o 0 */ #include &lt;stdio.h&gt; int main ( ) { int n , factorial = 1 ; printf ( "enter the value of n\n") ; scanf ( "%i" , &amp; n ) ; while ( n != 0 ) { factorial *= n ; n -- ; } printf ( "The factorial of n is\n%i\n" , factorial ) ; return 0; }


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

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


Write a program using while loop?

//program to find the factorial value f any number using while loop #include&lt;stdio.h&gt; void main() { int i,n,fact=1; printf("Enter the number\n"); scanf("%d",&amp;n); i=n; while (i&gt;=1) { fact=fact*i; i--; } printf("The factorial value=%d",fact); } the above is a program for calculating tha factorial value of any number which is entered by the user


C plus plus program to find factorial of given number using function overloading?

Use this function: long factorial(int N){if (N == 0){return 1;}else{return N*factorial(N-1);}}


Abap Program To find Factorial of number?

report zbharath. data:num type i value 5, fac type i value 0. perform fact using num changing fac. write:/ 'factorial of',num,'is',fac. form fact. using value(f-num) type i. changing f-fact type i. f-fact=1. while f-num ge 1. f-fact=f-fact*f-num. f-num=f-num-1. endwhile. endform.


Factorial in c program using for loop?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { int i,n,fact=1; clrscr(); printf("enter the number"); scanf("%d",&amp;n); for(i=1;i&lt;=n;i++) printf("%d",n); fact=fact*i; { printf("the factorial is=%d",fact); } getch(); } By:-Abhishek Goyal(goyal.abhi40@yahoo.com)


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

== == using recursions: unsigned int Factorial( unsigned int x) { if(x&gt;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&gt;0) { u32fact = u32fact *x; x--; } } }