Hello, We\'re working on pointers right now (no arrays yet) and this is my probl
ID: 3631641 • Letter: H
Question
Hello,
We're working on pointers right now (no arrays yet) and this is my problem. I'm only learning C, so please help me in that.
Write a program that reads a number from input and computes the value of the function
f(x) = (1+ (x2/(3x+6)) / (x2 - 5x)
Your program should input data and print the answer using the following format:
Enter a number x: 2.74
f(x) = -0.482997
Take into account the fact that this function cannot be evaluated for certain values of x.
Your program should test for these values. If the function cannot be computed for the
given input, the program should print:
f(x) is not defined
Hint: There is no need to consider complex numbers.
Explanation / Answer
#include<stdio.h>
#include<math.h>
int main()
{
float fx=0,x=0;
printf("Enter the value of X ");
scanf(" %f ",&x);
if((x*x-5*x)==0)
printf("f(x) is not defined");
else
if((3*x+6)<=0)
printf("f(x) is not defined ");
else
fx=( (1+( (x*x) /sqrt( (3*x+6) ) ) ) )/(x*x-5*x);
printf(" f(x) = %f ",fx);
return (0);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.