Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can anyone help me with this problem i dont really get it. It would be nice if y

ID: 3767027 • Letter: C

Question

Can anyone help me with this problem i dont really get it. It would be nice if you cpuld post the code for it. Case Study Follow-Up that determines the largest number for which your C++ program tlsy using the longdouble type. A factorial is the product number. For example, 10 factorial (written 10!) is 513 s Write a C++ program that determines the all numbers from tial exactly 1x2 x3 x 4x5 x6 x 7 x 8 x 9 x 10-3,628,800 its factorial exactly using the longdouble l exactly using the longdouble type. A factorial is puter can is the product of all numbers from I to the given number. For example, 10 factorial is the prodrc an represh from 1 to the given number. For example, 10 factorial ( As you can see, the factorial grows should keep multiplying the prior factorial by the next integer, ty Your program to be a large number very quickly. Your program factorial by the next integer, then subtract 1 and significant digits are truncated to al stored, then subtracting 1 should have no effect on the value. Because floa representations may not be exact, however, the expression should keep the difference between the factorial and the factorial minus 1 is less than check whether the ditterence between the factorial and the fac 1-an error tolerance. When the rence. When the maximum precision of the type is reached, and least. low the most signincant digits of the product to be ting-point abs ((number 1) - number) may not exactly equal 1. That's why you need to include a small error tolerance in the comparison. Use functional decomposition to solve this problem. Code the program using good d of progress, you may wish to output all of the intermediate factorial values. The greatest number and its factorial should be clearly labeled. Study Follow-Up How could you determine whether a hyphen should be counted as an end-of-word ymbol or a break in the word due to spacing issues?

Explanation / Answer

Here is the code for you. If you need any further modifications, just get back to me.

#include <iostream>
#include <cmath>
using namespace std;
long double factorial(int n)   //Function calculates the factorial of a given number.
{
if(n == 0)           //Ensures 0! is 1.
return 1;
return (long double)n * factorial(n-1);   //Else n! = n - (n-1)!.
}  
int main()
{
long double fact = 1;       //Initializing fact to 1, and number to 0.
int number = 0;
while(abs((fact-1) - fact) <= 1)   //While fact-1 - fact is less than or equal to 1.
{
cout<<"Factorial of "<<number<<" is: "<<fact<<" and abs((fact-1)-fact) is: "<<abs((fact-1)-fact)<<endl;
number++;                   //Increment the number.
fact = factorial(number);   //Calculate the fact for the next number.
}
cout<<"The largest factorial can be calculated for: "<<number-1<<", and "<<number-1<<"! = "<<factorial(number-1)<<endl;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote