1. Note: This program will be graded based on whether the required functionality were implemented correctly instead of whether it produces the correct output, for the functionality part.

Modify insert.c (attached, Project 2, #1), the insert0 detection function using pointer arithmetic. The function prototype should be the following. Name your program insert2.c.

void insert0(int n, int *a1, int *a2);

The function should use pointer arithmetic not subscripting to visit array elements. In other words, eliminate the loop index variables and all use of the [] operator in the function.

2. A C program can represent a real polynomial p(x) of degree n as an array of the real coefficients a 0 a 1, , a n.

p(x) = a0 + a1x + a2x^2 , an x^n

Write a C program that inputs a polynomial of degree 8 and then evaluates the polynomial at various values of x. The output should have two decimal digits

Enter the eight coefficients: 1.2 3 2.4 4 1 9.1 3 0
Enter x: 4.4
Output: 37552.73

1) Name your program poly.c

2) As part of the solution, write and call the function get_poly() with the following prototype. The get_poly() function should fill the array of eight coefficients.

void get_poly(double *coeff);

The get_poly() function should use pointer arithmetic not subscripting to visit array elements. In other words, eliminate the loop index variables and all use of the [] operator in the function.

3) As part of the solution, write and call the function eval_poly() with the following prototype.

double eval_poly(double *coeff, double x);

4) You might need the pow function in math.h library to calculate the result of raising x to the power y. The function prototype of the pow function:

double pow(double x, double y);

5) Compile the program with lm:

gcc -lm -Wall poly.c
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.