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

THe code works the first time thru but when i type in a new value for x it conti

ID: 3660305 • Letter: T

Question

THe code works the first time thru but when i type in a new value for x it continuosly keeps looping and doesnt let the user type in a new value i want to kno if there is a way to stop it from doing this so i can type in a new value for x thx for the help.

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


int main()
{
int count=0;
float sum=0,w,t,y,x;

printf("Enter value of x: ");
scanf("%f",&x);

while(x!=-1)
{
y=((x+3)*(x+4))/(2*(x+1));

printf("y: %.2f",y);
if(y>=1 || y<=10)
{
w=sqrt(y-1);
printf(" w: %.2f",w);
t=.143*w;
printf(" t: %.2f",t);
}
else
{
t=pow(pow(y,3)+1,4);
}

count++;
sum =t+sum;
printf(" %.2f",t);
printf("Enter value of x: ");
scanf("%.2f",&x);
}
sum=sum/count;//average
printf("%.2f",&sum);

return 0;
}

Explanation / Answer

Now look you are forcing your program to loop you have written while(x!=-1) that means the program will keep looping until you type x value = -1 u should modify you that particular line of command