Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Modify this program so it prints the median of numbers instead of the average of numbers #include #include avg.h #include /* run locally on 'server'
Modify this program so it prints the median of numbers instead of the average of numbers #include#include "avg.h" #include /* run locally on 'server' called by a remote client. */ static double sum_avg; /* * routine notice the _1 the version number * notice the client handle, not sued here but needs to be * a parameter */ double * average_1(input_data *input, CLIENT *client) { /* input is paramters were marshalled by genrated routine */ /* a pointer to a double, is set to begining of data array */ double *dp = input->input_data.input_data_val; u_int i; sum_avg = 0; /* iterate until end of number of times (data_len) */ for( i = 1; i <= input->input_data.input_data_len; i++ ) { sum_avg = sum_avg + *dp; /* add what ptrs points to ( '*' gets content ) */ dp++; } sum_avg = sum_avg / input->input_data.input_data_len; return( &sum_avg ); } /* * server stub 'average_1_svc function handle called in avg_svc that was * generated by rpcgen * FYI: * result = (*local)((char *)&argument, rqstp); * where local is (char *(*)(char *, struct svc_req *)) average_1_svc; */ double * average_1_svc(input_data *input, struct svc_req *svc) { CLIENT *client; return( average_1( input, client) ); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started