Write code in C++ The factorial function is used frequently in probability probl
ID: 3824337 • Letter: W
Question
Write code in C++
The factorial function is used frequently in probability problems. Write a program that uses a for statement the evaluate the factorials from 1 to 7. Print the results in tabular form. What difficulty might prevent you from calculating a factorial of 25? b) Write a program that uses a for statement to multiply a sequence of integers. Assume that the first integer input, signifies the number of values to be entered. Your program should read only one value per input statement. A typical input sequence might be 6 1 2 3 5 5 9 where 6 indicates that the subsequent values are to be multiplied.Explanation / Answer
#include int main (int argCount, char *argVal[]) { int i; // General purpose counter. int smallNum; // Holds the smallest number. int numSum; // Holds the sum of all numbers. int currentNum; // Holds the current number. int numCount; // Holds the count of numbers. // Get count of numbers and make sure it's in range 1 through 50. printf ("How many numbers will be entered (max 50)? "); scanf ("%d", &numCount); if ((numCount < 1) || (numCount > 50)) { printf ("Invalid count of %d. ", numCount); return 1; } printf(" Enter %d numbers then press enter after each entry: ", numCount); // Set initial sum to zero, numbers will be added to this. numSum = 0; // Loop, getting and processing all numbers. for (i = 0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.