More new questions »

Answered

/*mycfiles.wordpress.com Program for Factorial*/ #include #include void main() { int n,fact=1; clrscr(); printf("Enter any Number:\\n\\n"); scanf("%d",&n); w…hile(n>1) { fact=fact*n; n-; } printf("\\nFactorial is=%d",fact); getch(); } (MORE)

Answered

This program will compute N Factorial for any N, and does not suffer from overflow, because it uses a bin technique and handles each digit individually. For large values of N,… you may need to increase your run-time stack size. /* Portable arbitrary length decimal iterative */ /* one node of a linked list of digits, the first node being low-order */ struct _decimal { int digit; struct _decimal *next; }; typedef struct _decimal decimal; /* Portable arbitrary length decimal iterative */ /* Initialize the list - necessary on second pass, if main recoded */ void decimal_initialize (decimal *d, int n) { decimal *next, *nextsave; d->digit = n; nextsave = d->next; d->next = NULL; next = nextsave; while (next != NULL) { nextsave = next->next; free (next); next = nextsave; } return; } /* Portable arbitrary length decimal iterative */ /* Append a digit at the high order position */ void decimal_add_digit (decimal *d, int n) { decimal *new_digit = (decimal*) malloc (sizeof (decimal)); while (d->next != NULL) d = d->next; new_digit->digit = n; new_digit->next = NULL; d->next = new_digit; return; } /* Portable arbitrary length decimal iterative */ /* Print the digits in reverse order - recursive */ void decimal_print_digits (decimal *d, int last_digit) { if (d->next != NULL) decimal_print_digits (d->next, false); printf ("%d", d->digit); if (last_digit) printf("\\n"); return; } /* Portable arbitrary length decimal iterative */ /* multiply the list by N */ void decimal_multiply (decimal *d, int N) { int carry = 0; while (d != NULL) { d->digit = d->digit * N + carry; carry = d->digit / 10; d->digit %= 10; if (carry != 0 && d->next NULL) decimal_add_digit (d, 0); d = d->next; } return; } /* Portable arbitrary length decimal iterative */ /* Primary interative algorithm */ void decimal_NFactIterative (decimal *d, int N) { if (N < 2) { decimal_initialize (d, 1); return; } 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 ("%d", &N); } else { N = atoi (argv[1]); } printf ("Arbitrary: %u! = ", N); decimal_NFactIterative (&Decimal, N); decimal_print_digits (&Decimal, true); return 0; } (MORE)

Answered

include #include void main() { int i,fact=1,n; clrscr(); printf("\\nEnter the no of terms ="); scanf("%d",&n); for(i=1;i… (MORE)

Answered

include #include void main() { int i,n,fact=1; clrscr(); printf("enter the number"); scanf("%d",&n); for(i=1;i… (MORE)

Answered

In Technology

/*** returns N!, assume N >= 0 ***/ int Factorial(int n) { if (n … (MORE)

Answered

In Uncategorized

the 5s because it has better service but it dosent have diffrent colrs just silver gold and black

Answered

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 N char command = 'n'; do { cout > N; cout (MORE)

Answered

In Technology

Factorial in C++ is the same as factorial in mathematics. For a given integer, N, the factorial, denoted N!, is the product of all integers in the closed range 1 to N, where 0…! is 1. The problem with factorials is that the largest factorial you can store in a 64-bit integer is 20!. To cater for larger factorials you need a numeric library capable of handling larger integers, such as the GMP library. (MORE)

Answered

/*program for finding the factorial*/ void main() { int a,b=1; clrscr(); printf("Please enter any number to find its factorial\\n"); scanf("%d",&a); while(a>1) … { b=b*a; a--; } printf("factorial is %d",b); getch(); } (MORE)

Answered

20c + 5 = 5c + 65 Divide through by 5: 4c + 1 = c + 13 Subtract c from both sides: 3c + 1 = 13 Subtract 1 from both sides: 3c = 12 Divide both sides by 3: c = 4