Write a program that evaluates the function y = 2/x + 3 for the values of x that
ID: 2988856 • Letter: W
Question
Write a program that evaluates the function y = 2/x + 3 for the values of x that are between 1 and 10,
inclusive.
For each value of x, find the value of y with 2 digits of precision, with 4 digits of precision and in the
scientific notation. Make sure all the columns are aligned to the right side, as shown in the sample below.
Show all the results starting from x=1 until x=10
IMAGE OF OUTPUT: http://i.imgur.com/5tQwp9j.png
I wrote this to get it started but my for loop isnt working right
#include <stdio.h>
#include <math.h>
int main()
{
float x,ans;
x=1;
printf("The Function is :y = (2/x) + 3");
printf(" x y y y ------------------------------------------- ");
for (x=1;x>=5;x=x+1)
{
ans=(2/x)+3;
printf("abc");
}
return 0;
}
Explanation / Answer
instead of for (x=1;x>=5;x=x+1)
use
for (x=1;x<=5;x=x+1)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.