Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

An array is a versatile data structure. It can be used to directly represent pol

ID: 640928 • Letter: A

Question

An array is a versatile data structure. It can be used to directly represent polynomials in standard form by storing just the values of the coefficients of the polynomial in the boxes of the array. This homework focuses on polynomials and operations with polynomials. For all the problems in this homework, you may assume that the highest degree polynomial you will be required to accept as input is 13. You may also assume that all the polynomials have one real-valued variable x. 1. Write a C program that will read and display (in the same order), the degree N of a polynomial and all the coefficients in standard form for a polynomial of degree N. Remember N

Explanation / Answer

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#define MAXSIZE 10

voidmain()
{
int a[MAXSIZE];
int i, N,power,k;
float x, polySum;

clrscr();
for(k=0;k<2;k++){

printf("Enter the order of the polynomial ");
scanf("%d", &N);

printf("Enter the value of x ");
scanf("%f", &x);

/*Read the coefficients into an array*/

printf("Enter %d coefficients ",N+1);
for (i=0;i <= N;i++)
{
scanf("%d",&a[i]);
}

polySum = a[0];

for (i=1;i<= N;i++)
{
polySum = polySum * x + a[i];
}

power = N;

/*power--;*/

printf("Given polynomial is: ");
for (i=0;i<= N;i++)
{
if (power < 0)
{
break;
}

/* printing proper polynomial function*/
if (a[i] > 0)
printf(" + ");
else if (a[i] < 0)
printf(" - ");
else
printf (" ");
printf("%dx^%d ",abs(a[i]),power--);

}

printf(" Sum of the polynomial = %6.2f ",polySum);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote