Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

ISBN: 0262660709, 978-0262660709

More Books

Students also viewed these Databases questions

Question

i need answers of 8th question

Answered: 1 week ago

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago

Question

How was their resistance overcome?

Answered: 1 week ago