Commit e991223e by phkarl

Upload New File

parent 174e7c1d
Showing with 53 additions and 0 deletions
#include <stdio.h>
#include <math.h> // import of math.h library to use the mathematical features
int main(){
// Declaration of the variables
float A; // starting value
float H; // step
float YM;// limit of the function value YM
float i;// running variable
float X;// abscissa value
double Y;//result of the function
// Input of A, H and YM
printf("Enter starting value: ");
scanf("%f", &A);
printf("Enter step size: ");
scanf("%f", &H);
while(H < 0){// repeat the input if H is less than 0
printf("Step size must be greater than zero!\n");
printf("Enter step size again: ");
scanf("%f", &H);
}
printf("Enter the lower limit of the function value: ");
scanf("%f", &YM);
// Calculation of the function, Output
printf("x f(x)\n");// header of the table
i = 0;// initialize the running variable
Y = 1.7 * pow(10, 208);//max value of Y
while(i <= 14){
X = A + H * i;// calculate abscissa value
printf("%f ", X);// print abscissa value
if(0 < X && X <= 2){// if the X value is within the limit values
/*calculate the function with the
* previously calculated x value using the math.h library */
Y = 1 - ((1 - pow((4 - pow(X, 2)), 0.5)) / (40 * pow(X, 2) + pow(X, 0.5)));
if(YM > Y){/* if the limit of the function valuel
*is greater than the result of the function */
printf("The lower limit of the function value is reached!");
break;// end the loop
}
printf("%f\n", Y);// print the result of the function
}else if(X == 0){// in this case Y is infinite
printf("not avilable!\n");
}else{// in this case Y is complex
printf("complex number!\n");
}
i += 1;// increase the running variable by 1
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment