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

Simplify the following program without using goto function: #5. Write a program

ID: 3639268 • Letter: S

Question

Simplify the following program without using goto function:

#5. Write a program that approximate e by computing the value of
1 + 1/1! + 1/2! + 1/3! +... + 1/n!
where n is an integer entered by the user.

#include<stdio.h>
main()
{
int n,i,f=1,j;
float e = 1.0;

start:
printf("Enter n value: ");
scanf("%d",&n);
if(n<0)
{
printf("Please enter non-negetive value ");
goto start;
}
for(i = 1;i<=n;i++)
{
for(j = 1;j<=i;j++)
{
f = f*j;
}
e=e+((float)1/f);
f=1;
}
printf("Result is: %f ",(float)e);
getche();
}

Explanation / Answer

#include main() { int n=0,i,f=1,j; float e = 1.0; while(n
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