## Dec 30, 2011

### C Program to add two polynomials using structures.

C Program to add two polynomials using structures. Structure is a c composite data type, in which we can define all the data types under the same name or object. Size of the Structure is the size of all data types, plus any internal padding. the key word "struct" is used to declare the structure. A Polynomial is a mathematical expression involving a sum of powers in one or more variables multiplied by coefficients. Read more about C Programming Language .

```/***********************************************************
* You can use all the programs on  www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact info@c-program-example.com
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
*                      Happy Coding
***********************************************************/

#include < stdio.h >
#include < conio.h >
#define MAX 20

int exp, coef;
};

void main() {
int max1, max2, max3;
clrscr();
}

int i, texp;
i = 0;
printf("\nEnter exp ( use -1 to exit) : ");
scanf("%d", &texp);
while (texp != -1) {
p[i].exp = texp;
printf("\nEnter coef : ");
scanf("%d", &p[i].coef);
i++;
printf("\nEnter exp ( use -1 to exit) : ");
scanf("%d", &texp);
}
return (i);
}

//function to print polynomial
int i;
for (i = 0; i < max1; i++)
printf("%+dX%d ", p[i].coef, p[i].exp);
return;
}

intMAX1, max2;
{
int i,j,k;
i = j = k = 0;
while ( i <max1 && j <max2)
{
if( p1[i].exp > p2[j].exp)
{
p3[k] = p1[i];
k++;
i++;
}
else
if( p1[i].exp < p2[j].exp)
{
p3[k] = p2[j];
k++;
j++;
}
else
{
p3[k].exp = p1[i].exp;
p3[k].coef = p1[i].coef + p2[j].coef;
i++;
j++;
k++;
}
}
while( i <max1 )
{
p3[k] = p1[i];
k++;
i++;
}
while( j <max2 )
{
p3[k] = p2[j];
k++;
j++;
}
return(k);
}

```
```Array In C

C Data Structures

Simple C Programs```
You can easily select the code by double clicking on the code area above.

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!