Instructions
Objective
Write a C assignment program to calculate the max, average and other operations.
Requirements and Specifications
Solve the questions of finding average between numbers.
Solve the questions on finding max between numbers and other operations using the C programming language.
Source Code
AVERAGE
float average(float arr[], int n)
{
int i = 0;
float sum = 0.0;
for (i = 0; i {
sum += arr[i];
}
return sum / n;
}
EXAMPLE
#include
void myMethod(char input[])
{
printf("Hello %s !\n", input);
}
int main()
{
char input[] = "my friend";
myMethod(input);
}
MAX
int max(int n, int input[])
{
if (n == 1)
{
return input[0];
}
int cutMax = 0;
return input[n-1] > (cutMax = max(n-1, input)) ? input[n-1] : cutMax;
}