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

Write a program for the following in C. Create a program that prompts the user t

ID: 671059 • Letter: W

Question

Write a program for the following in C.

Create a program that prompts the user to enter an integer n, uses
Gasper's formula to approximate n!, and then displays the result. The
message displaying the result should look something like this:5! equals approximately 119.97003

Your program will be easier to debug if you use some intermediate val-
ues instead of trying to compute the result in a single expression. If you
are not getting the correct results, then you can compare the results of
your intermediate values to what you get when you do the calculations
by hand. Use at least two intermediate variables-one for 2n + 1/3 and one
for sqrt(2n+ 1/3 )pi. Display each of these intermediate values to simplify
debugging. Be sure to use a named constant for PI, and use the approxi-
mation 3.14159265. Test the program on non-negative integers less than 8.

Explanation / Answer

#include <stdio.h>
#include <math.h>

int main ()
{
float n;
printf("Enter a number ");
scanf("%f",&n);
float temp1 = 2 * n + 1/3;
temp1 = sqrt(temp1 * 3.14159265);
printf("sqrt(2n+1/3)= %f ", temp1);
float temp2 = pow(n,n) * pow(M_E ,-n);
printf("5! equals approximately %f",temp2*temp1);
return(0);
}

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