Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
emonyi
/
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
a53f4300
authored
6 years ago
by
emonyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
5347fc53
master
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
0 deletions
lab9/task2.c
lab9/task2.c
0 → 100644
View file @
a53f4300
#include <stdio.h>
#include <math.h>
float
average
(
int
array
[],
float
n
);
int
maximum
(
int
array
[],
int
n
);
int
minimum
(
int
array
[],
int
n
);
int
main
()
{
int
i
;
float
ave
;
int
n
;
int
small
;
int
big
;
int
output
;
printf
(
"Enter the size of array: "
);
scanf
(
"%d"
,
&
n
);
int
array
[
n
];
printf
(
"enter the elements of array: "
);
while
(
i
<
n
){
scanf
(
"%d"
,
&
array
[
i
]);
i
++
;
}
printf
(
"Select a calculation; 1 for Average
\n
2 for Minimum
\n
3 for maximum
\n
"
);
scanf
(
"%d"
,
&
output
);
switch
(
output
)
{
case
1
:
ave
=
average
(
array
,
n
);
printf
(
"%f"
,
ave
);
break
;
case
2
:
small
=
minimum
(
array
,
n
);
printf
(
"%d"
,
small
);
break
;
case
3
:
big
=
maximum
(
array
,
n
);
printf
(
"%d"
,
big
);
break
;
default
:
printf
(
" Enter Your Correct Choice."
);
break
;
}
return
0
;
}
float
average
(
int
array
[],
float
n
){
float
ave
=
array
[
0
];
int
i
=
0
,
sum
=
0
;
while
(
i
<
n
){
sum
=
sum
+
array
[
i
];
i
++
;
}
ave
=
sum
/
n
;
return
ave
;
}
int
minimum
(
int
array
[],
int
n
){
int
small
=
array
[
0
];
int
i
=
1
;
while
(
i
<
n
){
if
(
array
[
i
]
<
small
){
small
=
array
[
i
];
}
i
++
;
}
return
small
;
}
int
maximum
(
int
array
[],
int
n
){
int
big
=
array
[
0
];
int
i
=
1
;
while
(
i
<
n
){
if
(
array
[
i
]
>
big
){
big
=
array
[
i
];
}
i
++
;
}
return
big
;
}
This diff is collapsed.
Click to expand it.
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