Move files into directories

main
sgoudham 3 years ago
parent b4b57a1da5
commit d3e6bc5461

@ -4,7 +4,7 @@
void getInputArr(int *arrSize, int **arr);
void println(char *printString, float printNum);
int findMax(int arr[], int arrSize);
float calcAverage(int arr[], int arrSize);
float calcAverage(int *arr, int arrSize);
int main() {
int arr[] = {10, 20, 30, 40, 50};
@ -28,6 +28,8 @@ int main() {
printf("Element No.%i: %i\n", i, myArr[i]);
}
println("Average of Elements in Dynamic MyArray: ", calcAverage(myArr, myArrSize));
free(myArr);
return 0;
}
@ -36,7 +38,7 @@ void getInputArr(int *arrSize, int **myArr) {
printf("Please Enter Length of Array: \n");
scanf("%i", arrSize);
*myArr = (int *) malloc(*arrSize * sizeof(int));
*myArr = malloc(*arrSize * sizeof(int));
printf("Enter %i Numbers!\n", *arrSize);
for (int i = 0; i < *arrSize; i++) {
@ -58,10 +60,10 @@ int findMax(int arr[], int arrSize) {
return max;
}
float calcAverage(int arr[], int arrSize) {
float calcAverage(int *arr, int arrSize) {
int sum = 0;
for (int i = 0; i < arrSize; i++) {
sum += arr[i];
}
return sum / arrSize;
return (float) sum / arrSize;
}
Loading…
Cancel
Save