Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
tranvu
/
iax583
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
093b3bd5
authored
Oct 04, 2018
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Programming Homework 1 added
parent
bcd6ca80
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
0 deletions
Programming HW1/main.c
Programming HW1/prgramming hw1.pdf
Programming HW1/main.c
0 → 100644
View file @
093b3bd5
/*
* File: homework1.c
* Author: Tran Minh Huy Vu
*
* Created on October 4, 2018, 1:50 PM
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void
createTable
()
{
printf
(
"╒═══╤═══════════════╤═══════════════╕
\n
"
);
printf
(
"│ nr│ x │ y │
\n
"
);
printf
(
"╞═══╪═══════════════╪═══════════════╡
\n
"
);
}
int
number
=
1
;
void
addToTable
(
float
a
,
float
b
)
{
if
(
isnan
(
b
))
{
if
(
a
<
10
)
{
printf
(
"│ %d │ %f │ NaN │
\n
"
,
number
,
a
);
}
else
if
(
a
<
100
)
{
printf
(
"│ %d │ %f │ NaN │
\n
"
,
number
,
a
);
}
}
else
if
(
number
<
10
)
{
if
(
a
<
10
)
{
if
(
b
<
10
)
printf
(
"│ %d │ %f │ %f │
\n
"
,
number
,
a
,
b
);
else
if
(
b
<
100
)
printf
(
"│ %d │ %f │ %f │
\n
"
,
number
,
a
,
b
);
}
else
if
(
a
<
100
)
{
if
(
b
<
10
)
printf
(
"│ %d │ %f │ %f │
\n
"
,
number
,
a
,
b
);
else
if
(
b
<
100
)
printf
(
"│ %d │ %f │ %f │
\n
"
,
number
,
a
,
b
);
}
}
else
if
(
number
<
100
)
{
if
(
a
<
10
)
{
if
(
b
<
10
)
printf
(
"│%d │ %f │ %f │
\n
"
,
number
,
a
,
b
);
else
if
(
b
<
100
)
printf
(
"│ %d│ %f │ %f │
\n
"
,
number
,
a
,
b
);
}
else
if
(
a
<
100
)
{
if
(
b
<
10
)
printf
(
"│%d │ %f │ %f │
\n
"
,
number
,
a
,
b
);
else
if
(
b
<
100
)
printf
(
"│%d │ %f │ %f │
\n
"
,
number
,
a
,
b
);
}
}
number
++
;
}
void
endTable
()
{
printf
(
"╘═══╧═══════════════╧═══════════════╛"
);
}
int
main
()
{
float
x
,
y
,
lim
,
incre
;
printf
(
"Please input starting value: "
);
scanf
(
"%f"
,
&
x
);
printf
(
"Please input increment value: "
);
scanf
(
"%f"
,
&
incre
);
if
(
incre
<=
0
)
{
printf
(
"Increment have to be > 0"
);
return
1
;
}
printf
(
"Please input limit value: "
);
scanf
(
"%f"
,
&
lim
);
if
(
lim
<=
x
)
{
printf
(
"Limit have to be bigger than starting value"
);
return
1
;
}
printf
(
"Result for: ln(x + 5) / sqrt(7 + 5x + x^2)
\n\n
"
);
createTable
();
int
tooMuch
=
0
;
for
(
float
i
=
0
;
i
<
lim
&&
!
tooMuch
;
i
=
i
+
incre
)
{
y
=
log
(
i
+
5
)
/
sqrt
(
7
+
5
*
i
+
i
*
i
);
addToTable
(
i
,
y
);
if
(
isnan
(
y
))
y
=
lim
-
1
;
if
(
number
>=
16
)
tooMuch
=
1
;
}
endTable
();
return
(
EXIT_SUCCESS
);
}
Programming HW1/prgramming hw1.pdf
0 → 100644
View file @
093b3bd5
File added
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