Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

phkarl / IAX0583

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Switch branch/tag
  • IAX0583
  • homework1
  • Homework1v3.c
Find file
BlameHistoryPermalink
  • phkarl's avatar
    Upload New File · e991223e
    phkarl committed 6 years ago
    e991223e
Homework1v3.c 1.68 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
#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;
}