Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gürcan Güleç
/
iag0581
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1e993acd
authored
Oct 16, 2016
by
Gürcan Güleç
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating homework1.c
parent
8b6727a1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
33 deletions
homework1/homework1.c
homework1/homework1.c
View file @
1e993acd
/**
* File: homework1.c
* Author: Gurcan Gulec
* Created: 14 October 2016
* Last edit: 16 October 2016
*
* Description: Function homework.
*
*/
#include <stdio.h>
#include <stdio.h>
#include <math.h>
#include <math.h>
int
main
()
int
main
()
{
{
float
a
,
b
,
c
,
h
,
n
,
sum
,
between
,
value
,
result
;
float
a
,
b
,
c
,
h
,
n
,
sum
,
result
;
// ask for N and if N is less than "0" and greater than "15", ask again.
// ask for N and if N is less than "0" and greater than "15", ask again.
printf
(
"Please enter N (Between 0-15) : "
);
printf
(
"Please enter N (Between 0-15) : "
);
...
@@ -46,41 +56,40 @@ int main()
...
@@ -46,41 +56,40 @@ int main()
}
}
// calculate H+CH in a loop and increase the power of C
// calculate H+CH in a loop and increase the power of C
for
(
int
a
=
0
;
a
<
n
;
a
++
)
{
between
=
pow
(
c
,
value
)
*
h
;
value
++
;
}
// calculate the function
result
=
(
1
/
sqrt
(
pow
((
a
*
between
),
2
)
-
1
/
a
))
-
(
2
/
(
3
*
sqrt
(
5
-
pow
((
a
*
between
),
2
))));
if
(
result
!=
result
)
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
printf
(
"Complex
\n
"
);
}
else
if
(
result
==
INFINITY
)
{
printf
(
"Infinite
\n
"
);
}
else
{
{
printf
(
"Result is: %f
\n
"
,
result
);
// calculate A + H + CH...
}
float
toCalculate
=
a
;
for
(
int
j
=
0
;
j
<
i
;
j
++
)
{
toCalculate
+=
pow
(
c
,
j
)
*
h
;
}
// check the result. if it is infinite print out "Infinite". if it is a complex number, print out "Complex"
// calculate the function
//if (result != result)
result
=
(
1
/
sqrt
(
pow
((
a
*
toCalculate
),
2
)
-
1
/
a
))
-
(
2
/
(
3
*
sqrt
(
5
-
pow
((
a
*
toCalculate
),
2
))));
//{
// check if it is a complex number
// printf("Complex");
if
(
result
!=
result
)
//}
{
//else if(result == INFINITY)
printf
(
"%.2f
\t
"
,
toCalculate
);
//{
printf
(
"Complex
\n
"
);
// printf("Infinity");
}
//}
// check if it is infinite
//else
else
if
(
result
==
INFINITY
)
//{
{
// printf("Result is: %f", result);
printf
(
"%.2f
\t
"
,
toCalculate
);
//}
printf
(
"Infinite
\n
"
);
}
// show the number
else
{
printf
(
"%.2f
\t
"
,
toCalculate
);
printf
(
"%f
\n
"
,
result
);
}
}
return
0
;
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