Best Answer

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

Study guides

☆

Q: Using do while statement write cprogram for factorial number?

Write your answer...

Submit

Still have questions?

Continue Learning about Engineering

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

By the definition of a factorial, multiply all numbers up to the number given. For example (using Java code): int number = 5; // Sample value long factorial = 1; for (int i = 1; i <= number; i++) { factorial *= i; } System.out.println(number + "! = " + factorial);

1. flochart of cp Program to find factorial of number using function

#include <iostream> using namespace std; int main() { int i, number=0, factorial=1; // User input must be an integer number between 1 and 10 while(number<1 number>10) { cout << "Enter integer number (1-10) = "; cin >> number; } // Calculate the factorial with a FOR loop for(i=1; i<=number; i++) { factorial = factorial*i; } // Output result cout << "Factorial = " << factorial << endl;

factorial of a given number using pointers. #include<stdio.h> #include<conio.h> main() { int n, factorial; printf("\nEnter a number"); scanf("%d", &n); factcompute(n, &factorial); printf("\nThe factorial of %d is %d", n, factorial); } factcompute(a, b) int a, *b; { int m; *b = 1; for (m = 1; m <= a; m++) *b = *b * m; getch(); }

Related questions

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

By the definition of a factorial, multiply all numbers up to the number given. For example (using Java code): int number = 5; // Sample value long factorial = 1; for (int i = 1; i <= number; i++) { factorial *= i; } System.out.println(number + "! = " + factorial);

1. flochart of cp Program to find factorial of number using function

#include <iostream> using namespace std; int main() { int i, number=0, factorial=1; // User input must be an integer number between 1 and 10 while(number<1 number>10) { cout << "Enter integer number (1-10) = "; cin >> number; } // Calculate the factorial with a FOR loop for(i=1; i<=number; i++) { factorial = factorial*i; } // Output result cout << "Factorial = " << factorial << endl;

factorial of a given number using pointers. #include<stdio.h> #include<conio.h> main() { int n, factorial; printf("\nEnter a number"); scanf("%d", &n); factcompute(n, &factorial); printf("\nThe factorial of %d is %d", n, factorial); } factcompute(a, b) int a, *b; { int m; *b = 1; for (m = 1; m <= a; m++) *b = *b * m; getch(); }

kjhk

#include <iostream> #include <cctype> using std::cin; using std::cout; using std::endl; using std::tolower; long factorial(const int& N); int main() { int N = 0; //factorial of N char command = 'n'; do { cout << "Enter a number to calculate factorial: "; cin >> N; cout << endl << "Factorial of " << N << " is: " << factorial(N) << endl; cout << "Do you want to continue (y/n)?"; cin >> command; cout << endl; } while ('y' 0) { return 1; } else { return (N * factorial(N - 1)); } }

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

chutia mc,bc bhosdika

//Factorial using recursive function #include <stdio.h> //To increase the limit, the return type should be changed to unsigned long int fact(int number) { if (number == 0) return 1; return fact(number-1) * number; } int main(void) { int number ; printf("Enter the number to find the factorial:"); scanf("%d",&number); printf("The factorial is:%d",fact(number)); return 0; }

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

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

People also asked

Featured Questions