Study guides

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

Write your answer...

Submit

Still have questions?

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

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

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;

kjhk

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

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

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

chutia mc,bc bhosdika

w.a.p. to find factorial of a number using recursion

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

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

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

no answer....pls post

int factorial(int n) { int total = 1; for(; n > 1; n--) total *= n; return total; }

Following function calculates factorial of a number using recursion. unsigned int factorial(unsigned int a){if (a == 1)return 1;else{a *= factorial(a-1);return a;}} recursion n. see recursion.

public static int factorial(int n) { if (n == 1) { return 1; } else { return n * factorial(n - 1); } } \\then test by using main method

DATA: output TYPE i. PARAMETERS: p_num TYPE i. START-OF-SELECTION. PERFORM factorial USING p_num CHANGING output. WRITE:/ output. *&---------------------------------------------------------------------* *& Form factorial *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM factorial USING num CHANGING out. DATA: lv_num1 TYPE i, out1 TYPE i. IF num > 1. lv_num1 = num - 1. PERFORM factorial USING lv_num1 CHANGING out1. out = num * out1. ELSE. out = num. ENDIF. ENDFORM. " factorial

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

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

#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

#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

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

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

People also asked