answersLogoWhite

0


Best Answer

The program goes as follows:

#include

#include

void main()

{

int i, j=1;

printf("Enter the value of the integer whose factorial has to be calculated");

scanf("%d",i);

while(j

i = i*(i-1);

i--;

printf("The factorial of the integer is:%d",i);

getch();

}

OTHER METHOD.............

#include

#include

void main()

{

int n,f;

f=1;

printf("Enter the number:\n");

scanf("%d",&n);

while(n>0)

{

printf("%d",n);

f=f*n;

n--;

}

printf("The factorial of the integer is:%d",f);

getch();

}

another method

A very easy method,,,,,,

these is the work of 2nd year high school programming........... CVHS..

#include

int main()

{

char m;

int ans, i, n;

i=0;

m='y';

while((m=='y')(m=='Y'))

{

cout<<"Input a number ";

cin>>n;

if(n==0)

{

ans=1;

cout<<"The factorial of a number is "<

}

else

{

ans=1;

for(i=1;i<=n;i++)

{

ans=ans*i;

}

cout<<"The factorial of a number is "<

}

cout<<"\n Do you want to continue? (Y/N) ";

cin>>m;

}

return 0;

}

see,, its very easy!!!!

my new mathod

#include

#include

main()

{

int i,j,div,mod;

clrscr();

printf("enter any number = ");

scanf("%d",&i);

for(j=1;j<=i;j++)

{

mod=i%j;

if(mod==0)

{

printf("%d*",j);

div=i/j;

i=div;

j=1;

}

}

if(j==i)

{

printf("%d",i);

}

getch();

}

User Avatar

Wiki User

βˆ™ 12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

βˆ™ 14y ago

// 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);

}

This answer is:
User Avatar

User Avatar

Wiki User

βˆ™ 13y ago

There are several methods, some recursive, and iterative. Most suffer from lack of precision, because factorials get large fast. Here is a routine that compares various methods, including a method of arbitrary length decimals using linked lists. Note that, in order to compute vary large factorials, you will need to tell your linker/binder to increase the run-time stack size, because the linked list is created on the stack, and not in the heap.

// Factorial.cpp : Defines the entry point for the console application.

//

#include <stdlib.h>

#include <stdio.h>

/* Microsoft 32-bit iterative */

unsigned long NFactLongIterative (unsigned long N) {

unsigned long result = N;

if (N < 2) return 1;

if (N 2) {

decimal_initialize (d, 2);

return;

}

while (N > 2) {

decimal_multiply (d, N);

N--;

}

return;

}

/* Example main line */

/* Generates all variations to show differences in results */

int main (int argc, char *argv[]) {

int N;

decimal Decimal = {2, NULL};

if (argc < 2) {

printf ("Enter N (or use command line) : ");

scanf_s ("%d", &N);

} else {

N = atoi (argv[1]);

}

printf ("Long: %u! = %u\n", N, NFactLongIterative (N));

printf ("LongLong: %u! = %I64u\n", N, NFactLongLongIterative (N));

printf ("Recursive: %u! = %I64u\n", N, NFactLongLongRecursive (N));

printf ("Double: %u! = %.0f\n", N, NFactDouble (N));

/* note: arbitrary is exact - if the others don't match, arithmetic overflow occurred */

printf ("Arbitrary: %u! = ", N);

decimal_NFactIterative (&Decimal, N);

decimal_print_digits (&Decimal, true);

return 0;

}

This answer is:
User Avatar

User Avatar

Wiki User

βˆ™ 15y ago

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

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Using do while statement write cprogram for factorial number?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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;


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 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; }


How you can find a factorial of a number without using multiple operator?

If you really wanted to do this, you could simulate multiplication with repeated addition.


Program to find factorial of a number using inheritance?

/*71.PROGRAM TO FIND FACTORIAL OF A NUMBER USING RECURSION*/ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; int fact(int); void main() { int n,f; clrscr(); printf("Enter number whose factorial is to be calculated: "); scanf("%d",&amp;n); if(n&gt;0) { f=fact(n); printf("factorial of %d is %d",n,f); } else printf("Factorial of numbers less than 1 does not exist"); getch(); } int fact(int n) { int facto=1; if(n&gt;1) facto=n*fact(n-1); else return 1; return(facto); }

Related questions

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;


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


Program for finding the factorial of the two given number using constructor?

kjhk


By using call by reference find the factorial of a number?

chutia mc,bc bhosdika


How can you get the number 25 by using only number 4?

(4 times 4 factorial + 4) divided by 4 4 factorial + the square root of 4 minus (4 divided by 4)


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

no answer....pls post


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 make the number 11 using only 4' s?

(4!+4!-4)/4 ! means factorial, A factorial is every number below it multiplied Ex. 4!=4x3x2x1 which = 24(24+24-4)/4


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; }


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

int factorial(int n) { int i; int f=1; for(i=2;i&lt;=n;++i) 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


How you can find a factorial of a number without using multiple operator?

If you really wanted to do this, you could simulate multiplication with repeated addition.