Best Answer

Study guides

Q: Factorial in c program using for loop?

Write your answer...

Submit

Related questions

c program maze

using c program write factorial number with do..while statement

how to find the lcm using while loop

#include long factorial(int); main() { int i, n, c; printf("Enter the number of rows you wish to see in pascal triangle\n"); scanf("%d",&n); for ( i = 0 ; i < n ; i++ ) { for ( c = 0 ; c

int factorial(int n) { int i; int f=1; for(i=2;i<=n;++i) f*=i; return f; }

unsigned __int64 factorial(unsigned __int64 number) { unsigned __int64 factorial=1; while(number) factorial*=number--; return(factorial); }

Exactly what do you mean by 'C program in Java'

Wr

Not used

Yes, you can use for-loop in a C program compiled by Turbo C.

C program for Performing Binary Search http://thingsoverflow.com/?p=211

Yes, yes, please do.

take input n chodo

for (i=0; i<1; ++i) puts ("1123581321");

printf ("x")

Recursion is a replacement of loop in programming.Recursive programming techniques are not recommended as it may lead to non terminating conditions and finally program crash.Recursion is only recommended if the program demands it. Mainly Recursion is used for Operations like calculating factorial of a program.

odd loop means at least the loop execute once.

#!/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 } }

Yes, please do write.

A C, C#/Java code segment:int Factorial(int n) {if (n

Pros: it's easy ie: factorial int factorial(int n) { return n>=1 ? n * factorial(n-1) : 1; } Cons: your program can crash because of it's stack limit. In example above try n=200 :)

long factorial(int); int main() { int i, n, c; printf("Enter the number of rows you wish to see in pascal triangle\n"); scanf("%d",&n); for ( i = 0 ; i < n ; i++ ) { for ( c = 0 ; c

To get the factorial of a number, "n", do one of the following: 1) Multiply all numbers from one to "n". To do this, assign the number 1 to the result, then write a loop (from 1 to n) that will multiply result by each of the numbers the loop counter assumes. 2) Another method is to use recursion. If n = 0, return 1; otherwise, the factorial of n is equal to n * factorial(n - 1).

It depends on what program you design really

Reference: cprogramming-bd.com/c_page3.aspx#for%20loop

People also asked