# polynomial program in c, c program for polynomial addition, how to write a polynomial program in c language, polynomial c programming program, polynomial programming of c language

## Polynomial program in c using structure

#include<stdio.h>
#define MAX 10
struct polynomial
{
int degree;
int coef[MAX];

void CreatePoly(int);
void DisplayPoly(int);
void init(int); //Initialize all coefficients to 0

int main()
{
int n;
printf("\nProgram to add polynomials\n");
printf("\nEnter the number of polynomials : ");
scanf("%d",&n);
CreatePoly(n);
return(0);
}
void CreatePoly(int n)
{
int i,j,maxDeg=0,deg,temp;
init(n);
for(i=0;i<n;i++)
{
printf("\nEnter the Degree of Polynomial %d : ",i+1);
scanf("%d",&poly[i].degree);
if(poly[i].degree>maxDeg)
maxDeg=poly[i].degree;
printf("\nEnter the Coefficients of Polynomial of degree %d\n",poly[i].degree);
deg=MAX-poly[i].degree;
temp=poly[i].degree;
for(j=deg-1;j<MAX;j++)
{
printf("\nCoefficient of  x^%d : ",temp--);
scanf("%d",&poly[i].coef[j]);
}
}
DisplayPoly(n);
}
void DisplayPoly(int n)
{
int i,j,deg,temp;
printf("\nThe Polynomials are\n");
for(i=0;i<n;i++)
{
deg=MAX-poly[i].degree;
temp=poly[i].degree;
printf("Polynomial %d : ",i+1);
for(j=deg-1;j<MAX-1;j++)
printf("%+dx^%d ",poly[i].coef[j],temp--);
printf("%+d",poly[i].coef[j]);
printf("\n");
}
}
void init(int n)
{
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<MAX;j++)
poly[i].coef[j]=0;
}
for(j=0;j<MAX;j++)
}
void AddPoly(int n,int maxDeg)
{
int i,j,deg;
deg=MAX-maxDeg;
for(i=0;i<n;i++)
{
for(j=deg-1;j<MAX;j++)