Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phkarl
/
IAX0583
This project
Loading...
Sign in
Toggle navigation
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
Commit
e991223e
authored
Oct 15, 2018
by
phkarl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
174e7c1d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
homework1/Homework1v3.c
homework1/Homework1v3.c
0 → 100644
View file @
e991223e
#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
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment