Commit 825b7c7a by raliis

Upload New File

parent ab9b9e75
Showing with 62 additions and 0 deletions
#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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment