Question: IN C CODE #include #include #include struct node { int size; // holds the number of integers in the array pointed to by values int

IN C CODE

#include

#include

#include

struct node {

int size; // holds the number of integers in the array pointed to by values

int *values;

int sum;

struct node *next;

};

// fuction1 should return the number of nodes in the linked list,

// calculate the sum of each node's values and put the result into the node's variable sum,

// calculate and return the sum of the all the positive integers from all

// the nodes in the integer referenced by total_sum

// There are 40 points worth of test cases for function1

int function1(struct node *begin, int *total_sum) {

}

// function2 should read in size*size doubles from the file referenced by FILE * input and

// put the values into the size x size array myArray.

// myArray is 10 x 10 but you should make sure that 0 <= size <=9, if size is incorrect return -1 and do nothing

// fucntion2 should also return the sum of all the negative doubles that got stored in myArray

// There are 40 points worth of test cases for function2

double function2(FILE * input, double myArray[10][10],int size){

}

int main() {

// The TAs will manually check that you call function1 and function2 correctly and award 5 points for each correctly

// called function, using the above test cases

// There will also be 5 points awarded if your comments state what function1 does (return/modify)

// when called with your test case. There will be 5 points awarded if your comments state what function2 does (return/modify)

// when called with your test case.

/**** YOU SHOULDN'T CHANGE ANY OF THIS ****/

FILE * input;

double anArray[10][10];

struct node *begin = (struct node*)malloc(sizeof(struct node));

begin->next = (struct node *)malloc(sizeof(struct node));

begin->next->next = (struct node *)malloc(sizeof(struct node));

begin->next->next->next = NULL;

begin->size = 4;

begin->values = (int *)malloc(sizeof(int)*begin->size);

begin->values[0] = 5;

begin->values[1] = -5;

begin->values[2] = 8;

begin->values[3] = -4;

begin->next->size = 2;

begin->next->values = (int *)malloc(sizeof(int)*begin->next->size);

begin->values[0] = -5;

begin->values[1] = 16;

begin->next->next->size = 6;

begin->next->next->values = (int *)malloc(sizeof(int)*begin->next->next->size);

begin->next->next->values[0] = 10;

begin->next->next->values[1] = 11;

begin->next->next->values[2] = -14;

begin->next->next->values[3] = 17;

begin->next->next->values[4] = -19;

begin->next->next->values[5] = 25;

int fsum=0;

input = fopen("input.txt","r");

if (input == NULL) { printf("ERROR "); return;}

/******** PLACE YOUR CALLS TO FUNCTION1 and FUNCTION2 AND YOUR COMMENTS ABOUT WHAT THEY PRODUCE / DO AFTER THIS COMMENT */

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!