Write the C program that evaluates the value of y=pow(c,1+x), for x in the inter
ID: 3630555 • Letter: W
Question
Write the C program that evaluates the value of y=pow(c,1+x), for x in theinterval: a<x<=b.
Scan double values of a and b>a.
Scan a double value c>0.
Then, scan x and evaluate y and y/x.
If x is not from the required interval a<x<=b,
scan it again, shown in the output below.
If you don't scan it correctly twice in a row,
exit the program (as shown in the ouput below). To exit, use the function exit(0), but
don't forget to include stdlib.h above the main.
..........................................................................................
Your output should look like:
Enter a and b>a:
0.5 2.75
Enter c>0:
1.5
enter a double a<x<=b:
0.25
The x value is = 0.250000
You didn't enter x from a<x<=b!
Enter x from a<x<=b:
2.5
The y value is = 4.133514
The y/x value is = 1.653406
......
On the other hand, if you don't enter proper x twice in a row, you output
should look like:
Enter a and b>a:
0.5 2.75
Enter c>0:
1.5
enter a double a<x<=b:
0.25
The x value is = 0.250000
You didn't enter x from a<x<=b!
Enter x from a<x<=b:
3.1
You didn't enter x from a<x<=b! Exit!
*/
Explanation / Answer
please rate - thanks
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{double a,b,c,x,y;
printf("Enter a and b>a: ");
scanf("%lf",&a);
scanf("%lf",&b);
printf("Enter c>0: ");
scanf("%lf",&c);
printf("enter a double a<x<=b: ");
scanf("%lf",&x);
if(x<a||x>b)
{printf("The x value is = %.6f ",x);
printf("You didn't enter x from a<x<=b! ");
printf("Enter x from a<x<=b: ");
scanf("%lf",&x);
if(x<a||x>b)
{printf("You didn't enter x from a<x<=b! Exit! ");
exit(0);
}
}
y=pow(c,1+x);
printf("The y value is = %.6f ",y);
printf("The y/x value is = %.6f ",y/x);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.