Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C please. Provided starter code. just need to write a program to take an integer array, an integer representing the size of the array,

In C please. Provided starter code. just need to write a program to take an integer array, an integer representing the size of the array, and a result pointer. This function will calculate the average of all the elements in the array which are odd, and place the result in the result pointer. The function will return 0 on error, or the number of elements averaged on success. using avgOdd image text in transcribed

image text in transcribed

In this lab, you will cover pass by reference and error codes. You must analyze the problem given, determine what error conditions you may encounter, and make sure you code will not crash if an error condition is encountered. Test data is provided that you may optionally use. The first line in the data file is an integer representing the number of entries in the file, and the following lines are integers between 0 and 100. 1.1 avgOdd int avgOda(int *array, int size, tloat result); Info: This function will take an integer array, an integer representing the size of the array, and a result pointer. This function will calculate the average of all the elements in the array which are odd, and place the result in the result pointer. The function will return 0 on error, or the number of elements averaged on success. #include "lab1.h" int main() { FILE *file = fopen("numbers.txt", "r"); if(!file) { // Unable to open the specified file return EXIT_FAILURE; } int size; if(fscanf(file, "%d", &size) != 1) { fclose(file); 17 Unable to read the array size from the file return EXIT_FAILURE; 3 int array[size]; for(int i 0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions