Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
mahunt
/
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
b8ec1263
authored
Sep 17, 2018
by
mahunt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all
parent
7a8a2f41
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
172 additions
and
0 deletions
Lab 2/bonusTask.c
Lab 2/task1.c
Lab 2/task2.c
Lab 2/bonusTask.c
0 → 100644
View file @
b8ec1263
#include <stdio.h>
#include <stdlib.h>
int
main
()
{
int
arr
[
10
];
int
lessChecker
=
1
;
int
moreChecker
=
1
;
int
i
;
int
x
;
for
(
i
=
0
;
i
<
10
;
i
++
)
{
printf
(
"Please Enter a Value for Position: %d"
,
i
);
scanf
(
"%d"
,
&
arr
[
i
]);
}
int
store
=
arr
[
0
];
//less then checker
for
(
x
=
0
;
x
<
10
;
x
++
)
{
store
=
arr
[
x
];
for
(
i
=
x
+
1
;
i
<
10
;
i
++
)
{
if
(
store
<
arr
[
i
]
||
store
==
arr
[
i
])
{
lessChecker
=
0
;
}
}
}
//more then checker
for
(
x
=
0
;
x
<
10
;
x
++
)
{
store
=
arr
[
x
];
for
(
i
=
x
+
1
;
i
<
10
;
i
++
)
{
if
(
store
>
arr
[
i
]
||
store
==
arr
[
i
])
{
moreChecker
=
0
;
}
}
}
//result
if
(
lessChecker
==
1
)
{
printf
(
"It is descending."
);
}
else
if
(
moreChecker
==
1
)
{
printf
(
"It is ascending."
);
}
else
{
printf
(
"It is neither ascending or descending."
);
}
}
Lab 2/task1.c
0 → 100644
View file @
b8ec1263
#include <stdio.h>
#include <stdlib.h>
int
main
()
{
int
arr
[
10
];
arr
[
0
]
=
1
;
arr
[
1
]
=
2
;
arr
[
2
]
=
3
;
arr
[
3
]
=
4
;
arr
[
4
]
=
5
;
arr
[
5
]
=
6
;
arr
[
6
]
=
7
;
arr
[
7
]
=
8
;
arr
[
8
]
=
9
;
arr
[
9
]
=
10
;
int
i
;
//even
for
(
i
=
0
;
i
<
10
;
i
++
)
{
if
(
arr
[
i
]
%
2
==
0
)
{
printf
(
"
\n
%d"
,
arr
[
i
]);
}
}
printf
(
"
\n
"
);
//odd
for
(
i
=
0
;
i
<
10
;
i
++
)
{
if
(
arr
[
i
]
%
2
!=
0
)
{
printf
(
"
\n
%d"
,
arr
[
i
]);
}
}
printf
(
"
\n
"
);
//backward
for
(
i
=
9
;
i
>=
0
;
i
--
)
{
printf
(
"
\n
%d"
,
arr
[
i
]);
}
return
0
;
}
Lab 2/task2.c
0 → 100644
View file @
b8ec1263
#include <stdio.h>
#include <stdlib.h>
int
main
()
{
int
length
=
0
;
printf
(
"Please Enter Array Length"
);
scanf
(
"%d"
,
&
length
);
int
fib
[
length
];
int
i
;
printf
(
"
\n
%d"
,
length
);
if
(
length
>
0
)
{
fib
[
0
]
=
0
;
}
if
(
length
>
1
)
{
fib
[
1
]
=
1
;
}
//making fib squence
for
(
i
=
2
;
i
<=
length
;
i
++
)
{
fib
[
i
]
=
fib
[
i
-
1
]
+
fib
[
i
-
2
];
}
printf
(
"Even"
);
//even number print
for
(
i
=
0
;
i
<
length
;
i
++
)
{
if
(
fib
[
i
]
%
2
==
0
)
{
printf
(
"
\n
%d"
,
fib
[
i
]);
}
}
printf
(
"
\n
Odd"
);
//odd number print
for
(
i
=
0
;
i
<
length
;
i
++
)
{
if
(
fib
[
i
]
%
2
!=
0
)
{
printf
(
"
\n
%d"
,
fib
[
i
]);
}
}
printf
(
"
\n
Backward"
);
//backwar print
for
(
i
=
length
;
i
>=
0
;
i
--
)
{
printf
(
"
\n
%d"
,
fib
[
i
]);
}
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