answersLogoWhite

0


Best Answer

unsigned __int64 factorial(unsigned __int64 number)

{

unsigned __int64 factorial=1;

while(number)

factorial*=number--;

return(factorial);

}

User Avatar

Wiki User

โˆ™ 2014-01-12 17:03:03
This answer is:
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
User Avatar
Study guides

๐Ÿ““
Create a Study Guide

Add your answer:

Earn +20 pts
Q: How do you find the factorial using while loop in c plus plus?
Write your answer...
Submit
Related questions

Find factorial using for loop?

c program maze


How a C program to find LCM using while loop?

how to find the lcm using while loop


Write a program to find the factorial value of the given number using for loop?

In Java (not tested): long factorial(int number) { long result = 1; for (int i = 1; i


Factorial in c program using for loop?

#include int main() { int fact,Factorial; printf("Please Enter Factorial Number\n"); scanf("%d",&fact); Factorial=func_fact(fact); printf("factorial is %d\n",Factorial); } int func_fact(int number) { int i; int factorial=1; for(i=number;i>=1;i--) { factorial=factorial*i; } return factorial; }


How can you find factorial of an array?

The factorial function is the product of a single scalar value and all of its smaller values down to one. As such, it does not make sense to ask how to find the factorial of an array. Certainly, one could determine the factorial of each element of the array; simply setup a loop that iterates through the array and then performs the factorial function.


Find factorial at given number using do while loop?

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 = 1factor = 1while factor


How do you write an infinite loop using the while loop?

while (1) puts ("press Ctrl+C");


What is the advantages of using for loop than while loop?

when there is a need to do initialisation,condition check and increment in the same statement then for loop is used.otherwise while loop is used.


Write a program using while loop?

//program to find the factorial value f any number using while loop #include<stdio.h> void main() { int i,n,fact=1; printf("Enter the number\n"); scanf("%d",&n); i=n; while (i>=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


Write a shell program to find factorial using loop?

echo factorial of a number echo Enter the number read n i=1 fact=1 while test $i -le $n do fact=`expr $fact \* $i` i=`expr $i + 1` done echo The factorial of a number is $fact


How do you program using do-while loop in java?

dutkdtukuk


What is a factorial loop?

An example in Java, to compute 10!: int factorial = 1; for(int i = 1; i < 11; i++) { factorial *= i; }


How do you find factorial 5 in C programming?

to find the factorial we declare a variable n and initialize its value to 1 initiate a loop for example a for loop and multiply the numbers upto 5 code:- for(i=1,n=1;i<=5;i++) { n=n*i; }


What is the difference between while loop and for loop in c computer language?

For while loop you have to define conditions for the loop in loop's body. In, "for loop" case it's more natural and comportable. For loop is good for numeric simulations in other words when you are using only numbers. Loop while is very good for symbolic conditions, for instance, to check the condition that char1 == char2;


Comparison between for loop and do-while loop?

A for loop is typically used whenever a sequence needs to be performed a pre-determined number of times using a counter variable and a conditional expression. It is quite similar to a while loop except a while loop only has a conditional expression and is typically used for infinite loops. A do-while loop is similar to a while loop except that the conditional expression is evaluated at the end of the loop rather than at the beginning. Thus a do-while loop is guaranteed to execute at least once, whereas a for or while loop may not execute at all.


What is the differences between while loop and do while loop?

The while loop tests the condition at the top, while the do while loop tests the condition at the bottom. If the condition is initially false, the while loop will never execute, while the do while loop will execute once.


Reverse of the number using only while loop?

apple


What are the similarities of while loop and a do while loop?

They both loop


The while loop is a type of loop?

Is loop


What is the difference in while loop and do while loop?

The condition for a while loop is tested at the start of the loop. It is tested at the end of the loop for a do-while loop. The body of a do-while loop will always be executed at least once. Whereas for a while loop if the condition is false to start with, the body of the loop is never executed.


What is the main difference between a while loop and a do while loop?

In most computer programming languages using these constructs:while loop, the condition is tested beforeentering the loop (loop may be skipped completely)do while loop, the condition is tested aftercompleting the loop (loop will execute at least once)


What is a repeat until loop?

In C and C++, a repeat until loop is created using a do-while loop structure. A do-while loop executes at least once and terminates when the while condition evaluates false, re-iterating the loop if the evaluation is true. This is in contrast to for and while loops which evaluate the condition at the start of each iteration, and may not execute at all. Which loop structure you use is determined by the type of loop. If you need to count the iterations with a control variable and/or perform one or more actions at the end of each loop then a for loop is generally best. If the loop is simply conditional then a while loop is best. And if the loop must execute at least once, then a do-while loop is best.


What kind of loops are used in C?

For loop, while loop, do while loop and goto loop.


Write a C-like program fragment that calculate the factorial function for argment 12 with do while loop?

#!/usr/bin/perl print factorial($ARGV[11]); sub factorial { my($num) = @_; if($num == 1) { return 1; # stop at 1, factorial doesn't multiply times zero } else { return $num * factorial($num - 1); # call factorial function recursively } }


Why you need a for loop when you have already while loop or do while loop?

We need a for loop because the while and do-while loops do not make use of a control variable. Although you can implement a counter inside a while or do-while loop, the use of a control variable is not as self-evident as it is in a for loop. Aside from the use of a control variable, a for loop is largely the same as a while loop. However, it is quite different to a do-while loop, which always executes at least one iteration of the loop before evaluating the conditional expression. In a for and while loop, the conditional expression is always evaluated before entering the loop, which may result in the loop not executing at all.

People also asked

7 Write a C program to compute the factorial of a number using for loop?

View results

To find the factorial of a number between 1 and 8?

View results