Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
raliis
/
IAX0584
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
825b7c7a
authored
Feb 26, 2018
by
raliis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
ab9b9e75
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
rekursioon/m_74.c
rekursioon/m_74.c
0 → 100644
View file @
825b7c7a
#include <stdio.h>
int
scanM
();
// scans the size of the array
void
scanArr
(
int
M
,
float
*
Arr
);
// scans in the array
int
calc
(
float
*
Arr
,
int
M
);
// calculates P
int
main
(
void
)
{
int
M
;
M
=
scanM
();
float
Arr
[
M
];
scanArr
(
M
,
Arr
);
double
P
;
P
=
calc
(
Arr
,
M
);
printf
(
"P is equal to: %f"
,
P
);
return
0
;
}
int
scanM
()
{
int
M
;
printf
(
"Enter the size of the array (0-51): "
);
do
{
scanf
(
"%d"
,
&
M
);
}
while
(
M
<
1
||
M
>
50
);
return
M
;
}
void
scanArr
(
int
M
,
float
*
Arr
)
{
int
i
;
for
(
i
=
0
;
i
<
M
;
i
++
)
{
printf
(
"Enter the %d member of the array: "
,
i
);
scanf
(
"%f"
,
&
Arr
[
i
]);
}
/*for (i = 0; i < M; i++)
{
printf ("Element nr %d is: %.2f\n", i, Arr[i]);
}*/
}
int
calc
(
float
*
Arr
,
int
M
)
{
int
i
=
0
;
double
P
;
P
=
Arr
[
i
]
*
(
Arr
[
i
+
1
]
+
Arr
[
i
+
2
]);
i
++
;
return
P
;
}
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