Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
chazog
/
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
5378d838
authored
Dec 16, 2018
by
chazog
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
62abf84d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
0 deletions
Lab9/Task2.C
Lab9/Task2.C
0 → 100644
View file @
5378d838
#include <stdio.h>
#include <math.h>
float
average
(
int
array
[],
float
size
);
int
maximum
(
int
array
[],
int
size
);
int
minimum
(
int
array
[],
int
size
);
int
main
()
{
int
i
;
float
ave
;
int
size
;
int
min
;
int
max
;
int
op
;
printf
(
"Enter the size of array: "
);
scanf
(
"%d"
,
&
size
);
int
array
[
size
];
printf
(
"enter the elements of array: "
);
while
(
i
<
size
)
{
scanf
(
"%d"
,
&
array
[
i
]);
i
++
;
}
printf
(
"1.Average
\n
2.Minimum
\n
3.maximum
\n
"
);
scanf
(
"%d"
,
&
op
);
switch
(
op
)
{
case
1
:
ave
=
average
(
array
,
size
);
printf
(
"%f"
,
ave
);
break
;
case
2
:
min
=
minimum
(
array
,
size
);
printf
(
"%d"
,
min
);
break
;
case
3
:
max
=
maximum
(
array
,
size
);
printf
(
"%d"
,
max
);
break
;
default:
printf
(
" Enter Your Correct Choice."
);
break
;
}
return
0
;
}
float
average
(
int
array
[],
float
size
)
{
float
ave
=
array
[
0
];
int
i
=
0
,
sum
=
0
;
while
(
i
<
size
)
{
sum
=
sum
+
array
[
i
];
i
++
;
}
ave
=
sum
/
size
;
return
ave
;
}
int
minimum
(
int
array
[],
int
size
)
{
int
min
=
array
[
0
];
int
i
=
1
;
while
(
i
<
size
)
{
if
(
array
[
i
]
<
min
)
{
min
=
array
[
i
];
}
i
++
;
}
return
min
;
}
int
maximum
(
int
array
[],
int
size
)
{
int
max
=
array
[
0
];
int
i
=
1
;
while
(
i
<
size
)
{
if
(
array
[
i
]
>
max
)
{
max
=
array
[
i
];
}
i
++
;
}
return
max
;
}
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