SlideShare a Scribd company logo
Polynomial Addition
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<alloc.h>

void CreatePolyFirst();
void CreatePolySecond();                            //Function Protypes
void AddPoly();
void Attach(int, int, struct node *);

struct node
{
         int coef , exp;                            //Structure Definition
         struct node *next;

} *first=NULL, *second=NULL, *New=NULL, *temp1=NULL,
 *temp2=NULL, *result=NULL, *temp3=NULL;
Polynomial Addition
void main()
{
        int ch;
        clrscr();
        do
        {
                    printf("n***MENU***");
                    printf("n1.Create 1st Polynomial”);
                    printf(“n2.Create 2nd Polynomial”);
                    printf("n3.Add Both Polynomial
                    printf(”n4.Exit");

                    printf("nPlease Enter the Choice...");
                    scanf("%d",&ch);
Polynomial Addition


            switch(ch)
            {
                    case 1: CreatePolyFirst();
                            break;
                    case 2: CreatePolySecond();
                            break;
                    case 3: AddPoly();
                            break;
                    case 4: exit(0);

                     default: printf("n Invalid Choice...");
             }
    }while(ch!=4);
    getch();
}
void CreatePolyFirst()                           printf("nEnter the Exponent...");
{                                                scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending      if(first==NULL)
   Order...n");                                  {
   printf("nFor end enter 0.n");                       first=New;
                                                         temp1=New;
   while(1)                                      }
   {                                             else
         New=(struct node *) malloc (sizeof      {
         (struct node));                                 temp1->next=New;
         New->next=NULL;                                 temp1=New;
         printf("nEnter the Coefficient...");   }
         scanf("%d",&New->coef);                 if(New->exp==0)
         if(New->coef==0)                        break;
         break;                                  }}


   New                   



first = NULL
void CreatePolyFirst()                           printf("nEnter the Exponent...");
{                                                scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending      if(first==NULL)
   Order...n");                                  {
   printf("nFor end enter 0.n");                       first=New;
                                                         temp1=New;
   while(1)                                      }
   {                                             else
         New=(struct node *) malloc (sizeof      {
         (struct node));                                 temp1->next=New;
         New->next=NULL;                                 temp1=New;
         printf("nEnter the Coefficient...");   }
         scanf("%d",&New->coef);          5      if(New->exp==0)
         if(New->coef==0)                        break;
         break;                                  }}


   New         5        



first = NULL
void CreatePolyFirst()                           printf("nEnter the Exponent...");
{                                                scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending      if(first==NULL)
   Order...n");                                  {
   printf("nFor end enter 0.n");                       first=New;
                                                         temp1=New;
   while(1)                                      }
   {                                             else
         New=(struct node *) malloc (sizeof      {
         (struct node));                                 temp1->next=New;
         New->next=NULL;                                 temp1=New;
         printf("nEnter the Coefficient...");   }
         scanf("%d",&New->coef);                 if(New->exp==0)
         if(New->coef==0)                        break;
         break;                                  }}


   New         5         



first = NULL
void CreatePolyFirst()                           printf("nEnter the Exponent...");
{                                                scanf("%d",&New->exp);        2
   printf("nEnter Polynomial in Descending      if(first==NULL)
   Order...n");                                  {
   printf("nFor end enter 0.n");                       first=New;
                                                         temp1=New;
   while(1)                                      }
   {                                             else
         New=(struct node *) malloc (sizeof      {
         (struct node));                                 temp1->next=New;
         New->next=NULL;                                 temp1=New;
         printf("nEnter the Coefficient...");   }
         scanf("%d",&New->coef);                 if(New->exp==0)
         if(New->coef==0)                        break;
         break;                                  }}


   New         5    2    



first = NULL
void CreatePolyFirst()                           printf("nEnter the Exponent...");
{                                                scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending      if(first==NULL)
   Order...n");                                  {
   printf("nFor end enter 0.n");                      first=New;
                                                        temp1=New;
   while(1)                                      }
   {                                             else
         New=(struct node *) malloc (sizeof      {
         (struct node));                                temp1->next=New;
         New->next=NULL;                                temp1=New;
         printf("nEnter the Coefficient...");   }
         scanf("%d",&New->coef);                 if(New->exp==0)
         if(New->coef==0)                        break;
         break;                                  }}


   New         5    2    



first = NULL
void CreatePolyFirst()                           printf("nEnter the Exponent...");
{                                                scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending      if(first==NULL)
   Order...n");                                  {
   printf("nFor end enter 0.n");                       first=New;
                                                         temp1=New;
   while(1)                                      }
   {                                             else
         New=(struct node *) malloc (sizeof      {
         (struct node));                                 temp1->next=New;
         New->next=NULL;                                 temp1=New;
         printf("nEnter the Coefficient...");   }
         scanf("%d",&New->coef);                 if(New->exp==0)
         if(New->coef==0)                        break;
         break;                                  }}


   New,        5    2    
   first
void CreatePolyFirst()                           printf("nEnter the Exponent...");
{                                                scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending      if(first==NULL)
   Order...n");                                  {
   printf("nFor end enter 0.n");                       first=New;
                                                         temp1=New;
   while(1)                                      }
   {                                             else
         New=(struct node *) malloc (sizeof      {
         (struct node));                                 temp1->next=New;
         New->next=NULL;                                 temp1=New;
         printf("nEnter the Coefficient...");   }
         scanf("%d",&New->coef);                 if(New->exp==0)
         if(New->coef==0)                        break;
         break;                                  }}


   New,       5     2    
   first
           temp1
void CreatePolyFirst()                           printf("nEnter the Exponent...");
{                                                scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending      if(first==NULL)
   Order...n");                                  {
   printf("nFor end enter 0.n");                       first=New;
                                                         temp1=New;
   while(1)                                      }
   {                                             else
         New=(struct node *) malloc (sizeof      {
         (struct node));                                 temp1->next=New;
         New->next=NULL;                                 temp1=New;
         printf("nEnter the Coefficient...");   }
         scanf("%d",&New->coef);                 if(New->exp==0)
         if(New->coef==0)                        break;
         break;                                  }}


   New,       5     2    
   first
           temp1
void CreatePolyFirst()                               printf("nEnter the Exponent...");
{                                                    scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending          if(first==NULL)
   Order...n");                                      {
   printf("nFor end enter 0.n");                           first=New;
                                                             temp1=New;
   while(1)                                          }
   {                                                 else
         New=(struct node *) malloc (sizeof          {
         (struct node));                                     temp1->next=New;
         New->next=NULL;                                     temp1=New;
         printf("nEnter the Coefficient...");       }
         scanf("%d",&New->coef);                     if(New->exp==0)
         if(New->coef==0)                            break;
         break;                                      }}


   first      5    2        New                 


           temp1
void CreatePolyFirst()                               printf("nEnter the Exponent...");
{                                                    scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending          if(first==NULL)
   Order...n");                                      {
   printf("nFor end enter 0.n");                           first=New;
                                                             temp1=New;
   while(1)                                          }
   {                                                 else
         New=(struct node *) malloc (sizeof          {
         (struct node));                                     temp1->next=New;
         New->next=NULL;                                     temp1=New;
         printf("nEnter the Coefficient...");       }
         scanf("%d",&New->coef);          8          if(New->exp==0)
         if(New->coef==0)                            break;
         break;                                      }}


   first      5    2       New       8          


           temp1
void CreatePolyFirst()                               printf("nEnter the Exponent...");
{                                                    scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending          if(first==NULL)
   Order...n");                                      {
   printf("nFor end enter 0.n");                           first=New;
                                                             temp1=New;
   while(1)                                          }
   {                                                 else
         New=(struct node *) malloc (sizeof          {
         (struct node));                                     temp1->next=New;
         New->next=NULL;                                     temp1=New;
         printf("nEnter the Coefficient...");       }
         scanf("%d",&New->coef);                     if(New->exp==0)
         if(New->coef==0)                            break;
         break;                                      }}


   first      5     2       New        8        


           temp1
void CreatePolyFirst()                               printf("nEnter the Exponent...");
{                                                    scanf("%d",&New->exp);         1
   printf("nEnter Polynomial in Descending          if(first==NULL)
   Order...n");                                      {
   printf("nFor end enter 0.n");                           first=New;
                                                             temp1=New;
   while(1)                                          }
   {                                                 else
         New=(struct node *) malloc (sizeof          {
         (struct node));                                     temp1->next=New;
         New->next=NULL;                                     temp1=New;
         printf("nEnter the Coefficient...");       }
         scanf("%d",&New->coef);                     if(New->exp==0)
         if(New->coef==0)                            break;
         break;                                      }}


   first      5     2       New        8    1   


           temp1
void CreatePolyFirst()                               printf("nEnter the Exponent...");
{                                                    scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending          if(first==NULL)
   Order...n");                                      {
   printf("nFor end enter 0.n");                          first=New;
                                                            temp1=New;
   while(1)                                          }
   {                                                 else
         New=(struct node *) malloc (sizeof          {
         (struct node));                                    temp1->next=New;
         New->next=NULL;                                    temp1=New;
         printf("nEnter the Coefficient...");       }
         scanf("%d",&New->coef);                     if(New->exp==0)
         if(New->coef==0)                            break;
         break;                                      }}


   first      5     2       New        8    1   


           temp1
void CreatePolyFirst()                               printf("nEnter the Exponent...");
{                                                    scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending          if(first==NULL)
   Order...n");                                      {
   printf("nFor end enter 0.n");                           first=New;
                                                             temp1=New;
   while(1)                                          }
   {                                                 else
         New=(struct node *) malloc (sizeof          {
         (struct node));                                     temp1->next=New;
         New->next=NULL;                                     temp1=New;
         printf("nEnter the Coefficient...");       }
         scanf("%d",&New->coef);                     if(New->exp==0)
         if(New->coef==0)                            break;
         break;                                      }}


   first      5     2        New        8    1   


           temp1
void CreatePolyFirst()                               printf("nEnter the Exponent...");
{                                                    scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending          if(first==NULL)
   Order...n");                                      {
   printf("nFor end enter 0.n");                           first=New;
                                                             temp1=New;
   while(1)                                          }
   {                                                 else
         New=(struct node *) malloc (sizeof          {
         (struct node));                                     temp1->next=New;
         New->next=NULL;                                     temp1=New;
         printf("nEnter the Coefficient...");       }
         scanf("%d",&New->coef);                     if(New->exp==0)
         if(New->coef==0)                            break;
         break;                                      }}


   first      5     2        New        8    1   


                                        temp1
void CreatePolyFirst()                               printf("nEnter the Exponent...");
{                                                    scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending          if(first==NULL)
   Order...n");                                      {
   printf("nFor end enter 0.n");                           first=New;
                                                             temp1=New;
   while(1)                                          }
   {                                                 else
         New=(struct node *) malloc (sizeof          {
         (struct node));                                     temp1->next=New;
         New->next=NULL;                                     temp1=New;
         printf("nEnter the Coefficient...");       }
         scanf("%d",&New->coef);                     if(New->exp==0)
         if(New->coef==0)                            break;
         break;                                      }}


   first      5     2        New        8    1   


                                        temp1
void CreatePolyFirst()                               printf("nEnter the Exponent...");
{                                                    scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending          if(first==NULL)
   Order...n");                                      {
   printf("nFor end enter 0.n");                           first=New;
                                                             temp1=New;
   while(1)                                          }
   {                                                 else
          New=(struct node *) malloc (sizeof         {
         (struct node));                                     temp1->next=New;
         New->next=NULL;                                     temp1=New;
         printf("nEnter the Coefficient...");       }
         scanf("%d",&New->coef);                     if(New->exp==0)
         if(New->coef==0)                            break;
         break;                                      }}


              5    2                  8     1         New                  
   first

                                      temp1
void CreatePolyFirst()                               printf("nEnter the Exponent...");
{                                                    scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending          if(first==NULL)
   Order...n");                                      {
   printf("nFor end enter 0.n");                           first=New;
                                                             temp1=New;
   while(1)                                          }
   {                                                 else
          New=(struct node *) malloc (sizeof         {
         (struct node));                                     temp1->next=New;
         New->next=NULL;                                     temp1=New;
         printf("nEnter the Coefficient...");       }
         scanf("%d",&New->coef);          4          if(New->exp==0)
         if(New->coef==0)                            break;
         break;                                      }}


              5    2                  8    1          New       4          
   first

                                      temp1
void CreatePolyFirst()                               printf("nEnter the Exponent...");
{                                                    scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending          if(first==NULL)
   Order...n");                                      {
   printf("nFor end enter 0.n");                           first=New;
                                                             temp1=New;
   while(1)                                          }
   {                                                 else
          New=(struct node *) malloc (sizeof         {
         (struct node));                                     temp1->next=New;
         New->next=NULL;                                     temp1=New;
         printf("nEnter the Coefficient...");       }
         scanf("%d",&New->coef);                     if(New->exp==0)
         if(New->coef==0)                            break;
         break;                                      }}


              5     2                   8    1        New       4          
   first

                                       temp1
void CreatePolyFirst()                               printf("nEnter the Exponent...");
{                                                    scanf("%d",&New->exp);         0
   printf("nEnter Polynomial in Descending          if(first==NULL)
   Order...n");                                      {
   printf("nFor end enter 0.n");                           first=New;
                                                             temp1=New;
   while(1)                                          }
   {                                                 else
          New=(struct node *) malloc (sizeof         {
         (struct node));                                     temp1->next=New;
         New->next=NULL;                                     temp1=New;
         printf("nEnter the Coefficient...");       }
         scanf("%d",&New->coef);                     if(New->exp==0)
         if(New->coef==0)                            break;
         break;                                      }}


              5     2                   8    1        New      4    0    
   first

                                       temp1
void CreatePolyFirst()                               printf("nEnter the Exponent...");
{                                                    scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending          if(first==NULL)
   Order...n");                                      {
   printf("nFor end enter 0.n");                          first=New;
                                                            temp1=New;
   while(1)                                          }
   {                                                 else
          New=(struct node *) malloc (sizeof         {
         (struct node));                                    temp1->next=New;
         New->next=NULL;                                    temp1=New;
         printf("nEnter the Coefficient...");       }
         scanf("%d",&New->coef);                     if(New->exp==0)
         if(New->coef==0)                            break;
         break;                                      }}


              5     2                   8    1        New       4     0    
   first

                                       temp1
void CreatePolyFirst()                           printf("nEnter the Exponent...");
{                                                scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending      if(first==NULL)
   Order...n");                                  {
   printf("nFor end enter 0.n");                       first=New;
                                                         temp1=New;
   while(1)                                      }
   {                                             else
          New=(struct node *) malloc (sizeof     {
         (struct node));                                 temp1->next=New;
         New->next=NULL;                                 temp1=New;
         printf("nEnter the Coefficient...");   }
         scanf("%d",&New->coef);                 if(New->exp==0)
         if(New->coef==0)                        break;
         break;                                  }}


              5     2                   8    1     New       4     0    
   first

                                       temp1
void CreatePolyFirst()                           printf("nEnter the Exponent...");
{                                                scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending      if(first==NULL)
   Order...n");                                  {
   printf("nFor end enter 0.n");                       first=New;
                                                         temp1=New;
   while(1)                                      }
   {                                             else
          New=(struct node *) malloc (sizeof     {
         (struct node));                                 temp1->next=New;
         New->next=NULL;                                 temp1=New;
         printf("nEnter the Coefficient...");   }
         scanf("%d",&New->coef);                 if(New->exp==0)
         if(New->coef==0)                        break;
         break;                                  }}


              5     2                   8    1     New       4     0    
   first
                                                             temp1
void CreatePolyFirst()                           printf("nEnter the Exponent...");
{                                                scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending      if(first==NULL)
   Order...n");                                  {
   printf("nFor end enter 0.n");                       first=New;
                                                         temp1=New;
   while(1)                                      }
   {                                             else
          New=(struct node *) malloc (sizeof     {
         (struct node));                                 temp1->next=New;
         New->next=NULL;                                 temp1=New;
         printf("nEnter the Coefficient...");   }
         scanf("%d",&New->coef);                 if(New->exp==0)
         if(New->coef==0)                        break;
         break;                                  }}


              5     2                   8    1     New       4     0    
   first
                                                             temp1
void CreatePolyFirst()                           printf("nEnter the Exponent...");
{                                                scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending      if(first==NULL)
   Order...n");                                  {
   printf("nFor end enter 0.n");                       first=New;
                                                         temp1=New;
   while(1)                                      }
   {                                             else
          New=(struct node *) malloc (sizeof     {
         (struct node));                                 temp1->next=New;
         New->next=NULL;                                 temp1=New;
         printf("nEnter the Coefficient...");   }
         scanf("%d",&New->coef);                 if(New->exp==0)
         if(New->coef==0)                        break;
         break;                                  }}


   first      5     2                   8    1               4     0
void CreatePolySecond()                          printf("nEnter the Exponent...");
{                                                scanf("%d",&New->exp);
   printf("nEnter Polynomial in Descending      if(Second==NULL)
   Order...n");                                  {
   printf("nFor end enter 0.n");                      second=New;
                                                        temp2=New;
   while(1)                                      }
   {                                             else
          New=(struct node *) malloc (sizeof     {
         (struct node));                                temp2->next=New;
         New->next=NULL;                                temp2=New;
         printf("nEnter the Coefficient...");   }
         scanf("%d",&New->coef);                 if(New->exp==0)
         if(New->coef==0)                        break;
         break;                                  }}


second        4     4                   7    2               2     1
void AddPoly()                                 New->next=NULL;
{                                              if(p->exp==q->exp)
   struct node *p,*q,*r; int x;                {
   if(first==NULL || second==NULL)                 x=p->coef+q->coef;
   {                                               if(x!=0)
          printf("nYour First or Second           Attach(x,p->exp,New);
          Polynomial is Invalid...");              p=p->next;
          return;                                  q=q->next;
   }                                           }
   p=first; q=second;                           else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL) .                  {
   {                                               Attach(q->coef,q->exp,New);
          New=(struct node *) malloc (sizeof       q=q->next;
          (struct node));                      }


   first      5    2                  8    1                 4    0    



second        4    4                  7    2                 2    1
void AddPoly()                                  New->next=NULL;
{                                               if(p->exp==q->exp)
   struct node *p,*q,*r; int x;                 {
   if(first==NULL || second==NULL)                  x=p->coef+q->coef;
   {                                                if(x!=0)
           printf("nYour First or Second           Attach(x,p->exp,New);
           Polynomial is Invalid...");              p=p->next;
           return;                                  q=q->next;
   }                                            }
   p=first; q=second;                            else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL)                     {
   {                                                Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof       q=q->next;
           (struct node));                      }

   first       5    2                  8    1                 4    0    
           p
second         4    4                  7    2                 2    1    
           q
void AddPoly()                                  New->next=NULL;
{                                               if(p->exp==q->exp)
   struct node *p,*q,*r; int x;                 {
   if(first==NULL || second==NULL)                  x=p->coef+q->coef;
   {                                                if(x!=0)
           printf("nYour First or Second           Attach(x,p->exp,New);
           Polynomial is Invalid...");              p=p->next;
           return;                                  q=q->next;
   }                                            }
   p=first; q=second;                            else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL) .                   {
   {                                                Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof       q=q->next;
           (struct node));                      }

   first       5    2                  8    1                 4    0    
           p
second         4    4                  7    2                 2    1    
           q
void AddPoly()                                  New->next=NULL;
{                                               if(p->exp==q->exp)          2==4
   struct node *p,*q,*r; int x;                 {
   if(first==NULL || second==NULL)                  x=p->coef+q->coef;
   {                                                if(x!=0)
           printf("nYour First or Second           Attach(x,p->exp,New);
           Polynomial is Invalid...");              p=p->next;
           return;                                  q=q->next;
   }                                            }
   p=first; q=second;                            else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL)                     {
   {                                                Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof       q=q->next;
           (struct node));                      }

   first       5   2                  8    1                  4    0    
           p
second         4   4                  7    2                  2    1    
           q
   New
void AddPoly()                                  New->next=NULL;
{                                               if(p->exp==q->exp)
   struct node *p,*q,*r; int x;                 {
   if(first==NULL || second==NULL)                  x=p->coef+q->coef;
   {                                                if(x!=0)
           printf("nYour First or Second           Attach(x,p->exp,New);
           Polynomial is Invalid...");              p=p->next;
           return;                                  q=q->next;
   }                                            }
   p=first; q=second;                            else if(p->exp<q->exp)     2<4
   while(p!=NULL && q!=NULL)                     {
   {                                                Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof       q=q->next;
           (struct node));                      }

   first       5    2                  8    1                 4    0    
           p
second         4    4                  7    2                 2    1    
           q
   New
void AddPoly()                                  New->next=NULL;
{                                               if(p->exp==q->exp)
   struct node *p,*q,*r; int x;                 {
   if(first==NULL || second==NULL)                  x=p->coef+q->coef;
   {                                                if(x!=0)
           printf("nYour First or Second           Attach(x,p->exp,New);
           Polynomial is Invalid...");              p=p->next;
           return;                                  q=q->next;
   }                                            }
   p=first; q=second;                            else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL)                     {
   {                                                Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof       q=q->next;
           (struct node));                      }

   first       5    2                  8    1                 4    0   
           p
second         4    4                  7    2                 2    1   
           q
   New
void Attach(int c,int e,struct node *d) .           else
{                   (4, 4, New)                            {
                                                                   temp3->next=d;
           if(result==NULL)                                        temp3=d;
           {                                                       temp3->coef=c;
                     result=d;                                     temp3->exp=e;
                     temp3=New;                            }
                     temp3->coef=c;                 }
                     temp3->exp=e;
           }




   first       5     2                      8   1              4    0   
           p
               4     4                      7   2              2    1   
second
           q
   New                                                                     result= NULL
void Attach(int c,int e,struct node *d) .               else
{                   (4, 4, New)                         {
                                                                   temp3->next=d;
           if(result==NULL)                                        temp3=d;
           {                                                       temp3->coef=c;
                     result=d;                                     temp3->exp=e;
                     temp3=New;                         }
                     temp3->coef=c;                 }
                     temp3->exp=e;
           }




   first       5     2                      8   1              4    0   
           p
               4     4                      7   2              2    1   
second
           q
   New                           result, temp3
void Attach(int c,int e,struct node *d) .               else
{                   (4, 4, New)                         {
                                                                   temp3->next=d;
           if(result==NULL)                                        temp3=d;
           {                                                       temp3->coef=c;
                     result=d;                                     temp3->exp=e;
                     temp3=New;                         }
                     temp3->coef=c;                 }
                     temp3->exp=e;
           }




   first       5     2                      8   1              4    0   
           p
               4     4                      7   2              2    1   
second
           q
   New         4     4           result, temp3
void AddPoly()                                  New->next=NULL;
{                                               if(p->exp==q->exp)
   struct node *p,*q,*r; int x;                 {
   if(first==NULL || second==NULL)                  x=p->coef+q->coef;
   {                                                if(x!=0)
           printf("nYour First or Second           Attach(x,p->exp,New);
           Polynomial is Invalid...");              p=p->next;
           return;                                  q=q->next;
   }                                            }
   p=first; q=second;                            else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL)                     {
   {                                                Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof       q=q->next;
           (struct node));                      }

   first       5    2                  8    1                 4    0    
           p
second         4    4                  7    2                 2    1    
                                  q
    res,       4    4    
  temp3
void AddPoly()                                  New->next=NULL;
{                                               if(p->exp==q->exp)
   struct node *p,*q,*r; int x;                 {
   if(first==NULL || second==NULL)                  x=p->coef+q->coef;
   {                                                if(x!=0)
           printf("nYour First or Second           Attach(x,p->exp,New);
           Polynomial is Invalid...");              p=p->next;
           return;                                  q=q->next;
   }                                            }
   p=first; q=second;                            else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL)                     {
   {                                                Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof       q=q->next;
           (struct node));                      }

   first       5   2                  8    1                  4    0    
           p
second         4   4                  7    2                  2    1    
                               q
    res,       4   4       New                 
   temp3
void AddPoly()                                  New->next=NULL;
{                                               if(p->exp==q->exp)          2==2
   struct node *p,*q,*r; int x;                 {
   if(first==NULL || second==NULL)                  x=p->coef+q->coef;
   {                                                if(x!=0)
           printf("nYour First or Second           Attach(x,p->exp,New);
           Polynomial is Invalid...");              p=p->next;
           return;                                  q=q->next;
   }                                            }
   p=first; q=second;                            else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL)                     {
   {                                                Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof       q=q->next;
           (struct node));                      }

   first       5    2                  8    1                 4    0    
           p
second         4    4                  7    2                 2    1    
                                q
     res,      4    4       New                
    temp3
void AddPoly()                                  New->next=NULL;
{                                               if(p->exp==q->exp)
   struct node *p,*q,*r; int x;                 {
   if(first==NULL || second==NULL)                  x=p->coef+q->coef;      x= 5+7=12
   {                                                if(x!=0)
           printf("nYour First or Second           Attach(x,p->exp,New);
           Polynomial is Invalid...");              p=p->next;
           return;                                  q=q->next;
   }                                            }
   p=first; q=second;                            else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL)                     {
   {                                                Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof       q=q->next;
           (struct node));                      }

   first       5    2                  8    1                 4    0    
           p
second         4    4                  7    2                 2    1    
                                q
     res,      4    4       New                
    temp3
void AddPoly()                                      New->next=NULL;
{                                                   if(p->exp==q->exp)
   struct node *p,*q,*r; int x;                     {
   if(first==NULL || second==NULL)                      x=p->coef+q->coef;
   {                                                    if(x!=0)
           printf("nYour First or Second               Attach(x,p->exp,New);
           Polynomial is Invalid...");                  p=p->next;
           return;                                      q=q->next;
   }                                                }
   p=first; q=second;                                else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL)                         {
   {                                                    Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof           q=q->next;
           (struct node));                          }

   first       5    2                  8    1                     4    0    
           p
second         4    4                  7    2                     2    1    
                                  q
     res,      4    4                  12       2   
    temp3
void AddPoly()                                      New->next=NULL;
{                                                   if(p->exp==q->exp)
   struct node *p,*q,*r; int x;                     {
   if(first==NULL || second==NULL)                      x=p->coef+q->coef;
   {                                                    if(x!=0)
           printf("nYour First or Second               Attach(x,p->exp,New);
           Polynomial is Invalid...");                  p=p->next;
           return;                                      q=q->next;
   }                                                }
   p=first; q=second;                                else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL)                         {
   {                                                    Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof           q=q->next;
           (struct node));                          }

   first       5    2                  8    1                     4    0    
                                 p
second         4    4                  7    2                     2    1    
                                                             q
     res,      4    4                  12       2   
    temp3
void AddPoly()                                        New->next=NULL;
{                                                     if(p->exp==q->exp)
   struct node *p,*q,*r; int x;                       {
   if(first==NULL || second==NULL)                        x=p->coef+q->coef;
   {                                                      if(x!=0)
           printf("nYour First or Second                 Attach(x,p->exp,New);
           Polynomial is Invalid...");                    p=p->next;
           return;                                        q=q->next;
   }                                                  }
   p=first; q=second;                                  else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL)                           {
   {                                                      Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof             q=q->next;
           (struct node));                            }

   first      5    2                  8       1                     4    0    
                                p
second        4    4                  7       2                     2    1    
                                                               q
     res      4    4                12    2            New               
                                      temp3
void AddPoly()                                         New->next=NULL;
{                                                      if(p->exp==q->exp)          1==1
   struct node *p,*q,*r; int x;                        {
   if(first==NULL || second==NULL)                         x=p->coef+q->coef;
   {                                                       if(x!=0)
           printf("nYour First or Second                  Attach(x,p->exp,New);
           Polynomial is Invalid...");                     p=p->next;
           return;                                         q=q->next;
   }                                                   }
   p=first; q=second;                                   else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL)                            {
   {                                                       Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof              q=q->next;
           (struct node));                             }

   first       5    2                  8       1                     4    0       
                                 p
second         4    4                  7       2                     2    1       
                                                                q
     res       4    4                12    2            New                  
                                       temp3
void AddPoly()                                         New->next=NULL;
{                                                      if(p->exp==q->exp)
   struct node *p,*q,*r; int x;                        {
   if(first==NULL || second==NULL)                         x=p->coef+q->coef;      x=8+2=10
   {                                                       if(x!=0)
           printf("nYour First or Second                  Attach(x,p->exp,New);
           Polynomial is Invalid...");                     p=p->next;
           return;                                         q=q->next;
   }                                                   }
   p=first; q=second;                                   else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL)                            {
   {                                                       Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof              q=q->next;
           (struct node));                             }

   first       5    2                  8       1                     4    0       
                                 p
second         4    4                  7       2                     2    1       
                                                                q
     res       4    4                12    2            New                  
                                       temp3
void AddPoly()                                     New->next=NULL;
{                                                  if(p->exp==q->exp)
   struct node *p,*q,*r; int x;                    {
   if(first==NULL || second==NULL)                     x=p->coef+q->coef;
   {                                                   if(x!=0)
           printf("nYour First or Second              Attach(x,p->exp,New);
           Polynomial is Invalid...");                 p=p->next;
           return;                                     q=q->next;
   }                                               }
   p=first; q=second;                               else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL)                        {
   {                                                   Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof          q=q->next;
           (struct node));                         }

   first       5    2                  8       1                 4    0       
                                 p
second         4    4                  7       2                 2    1       
                                                            q
     res       4    4                12    2                  10 1        
                                                            temp3
void AddPoly()                                     New->next=NULL;
{                                                  if(p->exp==q->exp)
   struct node *p,*q,*r; int x;                    {
   if(first==NULL || second==NULL)                     x=p->coef+q->coef;
   {                                                   if(x!=0)
           printf("nYour First or Second              Attach(x,p->exp,New);
           Polynomial is Invalid...");                 p=p->next;
           return;                                     q=q->next;
   }                                               }
   p=first; q=second;                               else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL)                        {
   {                                                   Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof          q=q->next;
           (struct node));                         }

   first       5    2                  8       1                 4    0       
                                                            p
second         4    4                  7       2                 2    1       
                                                                                     q=NULL
     res       4    4                12    2                  10 1        
                                                            temp3
void AddPoly()                                     New->next=NULL;
{                                                  if(p->exp==q->exp)
   struct node *p,*q,*r; int x;                    {
   if(first==NULL || second==NULL)                     x=p->coef+q->coef;
   {                                                   if(x!=0)
           printf("nYour First or Second              Attach(x,p->exp,New);
           Polynomial is Invalid...");                 p=p->next;
           return;                                     q=q->next;
   }                                               }
   p=first; q=second;                               else if(p->exp<q->exp)
   while(p!=NULL && q!=NULL)                        {
   {                                                   Attach(q->coef,q->exp,New);
           New=(struct node *) malloc (sizeof          q=q->next;
           (struct node));                         }

   first       5    2                  8       1                 4    0       
                                                            p
second         4    4                  7       2                 2    1       
                                                                                     q=NULL
     res       4    4                12    2                  10 1        
                                                            temp3
else                                             printf("nAddition of Both Polynomial...n");
{                                                if(result==NULL)
    Attach(p->coef, p->exp, New);                {
    p=p->next;                                       printf("0"); return;
}}                                               }
while(p!=NULL)                                   while(result!=NULL)
{                                                {
    Attach(p->coef,p->exp,p);                        printf("%dx^%d",New->coef,New->exp);
    p=p->next;}                                      if(result->next!=NULL)
while(q!=NULL)                                       printf(" + ");
{                                                    New=New->next;
    Attach(p->coef,p->exp,q);                     }
    q=q->next;}                                  }



   first      5    2                 8       1                  4    0       
                                                           p
second        4    4                 7       2                  2    1       
                                                                                   q=NULL
     res      4    4                12   2                  10 1         
                                                          temp3
else                                             printf("nAddition of Both Polynomial...n");
{                                                if(result==NULL)
    Attach(p->coef, p->exp, New);                {
    p=p->next;                                       printf("0"); return;
}}                                               }
while(p!=NULL)                                   while(result!=NULL)
{                                                {
    Attach(p->coef,p->exp,p);                        printf("%dx^%d",New->coef,New->exp);
    p=p->next;}                                      if(result->next!=NULL)
while(q!=NULL)                                       printf(" + ");
{                                                    New=New->next;
    Attach(p->coef,p->exp,q);                     }
    q=q->next;}                                  }



   first      5    2                 8       1                   4       0   
                                                                                    p=NULL
second        4    4                 7       2                   2       1   
                                                                                     q=NULL
     res      4    4                12   2                  10       1              4 0  
                                                                                 temp3
else                                             printf("nAddition of Both Polynomial...n");
{                                                if(result==NULL)
    Attach(p->coef, p->exp, New);                {
    p=p->next;                                       printf("0"); return;
}}                                               }
while(p!=NULL)                                   while(result!=NULL)
{                                                {
    Attach(p->coef,p->exp,p);                        printf("%dx^%d",New->coef,New->exp);
    p=p->next;}                                      if(result->next!=NULL)
while(q!=NULL)                                       printf(" + ");
{                                                    New=New->next;
    Attach(p->coef,p->exp,q);                     }
    q=q->next;}                                  }



   first      5    2                 8       1                   4       0   
                                                                                   p=NULL
second        4    4                 7       2                   2       1   
                                                                                   q=NULL
     res      4    4                12   2                  10       1           4   0
else                                         printf("nAddition of Both Polynomialn");
{                                            if(result==NULL)
    Attach(p->coef, p->exp, New);            {
    p=p->next;                                   printf("0"); return;
}}                                           }
while(p!=NULL)                               while(result!=NULL)
{                                            {
    Attach(p->coef,p->exp,p);                    printf("%dx^%d",New->coef,New-
    p=p->next;}                                  >exp);
while(q!=NULL)                                   if(result->next!=NULL)
{                                                printf(" + ");
    Attach(p->coef,p->exp,q);                    New=New->next;
    q=q->next;}                               }
                                             }


     res    4    4                  12   2            10   1             4   0    

 res - > 4x^4 + 12x^2 + 10x^1 + 4

More Related Content

What's hot

The Ring programming language version 1.9 book - Part 91 of 210
The Ring programming language version 1.9 book - Part 91 of 210The Ring programming language version 1.9 book - Part 91 of 210
The Ring programming language version 1.9 book - Part 91 of 210
Mahmoud Samir Fayed
 
Os lab 1st mid
Os lab 1st midOs lab 1st mid
Os lab 1st mid
Murali Kummitha
 
Time-driven applications
Time-driven applicationsTime-driven applications
Time-driven applications
Piotr Horzycki
 
20070329 Java Programing Tips
20070329 Java Programing Tips20070329 Java Programing Tips
20070329 Java Programing TipsShingo Furuyama
 
Travel management
Travel managementTravel management
Travel management1Parimal2
 
Operating System Lab Manual
Operating System Lab ManualOperating System Lab Manual
Operating System Lab Manual
Bilal Mirza
 
The Ring programming language version 1.5.3 book - Part 88 of 184
The Ring programming language version 1.5.3 book - Part 88 of 184The Ring programming language version 1.5.3 book - Part 88 of 184
The Ring programming language version 1.5.3 book - Part 88 of 184
Mahmoud Samir Fayed
 
Are we ready to Go?
Are we ready to Go?Are we ready to Go?
Are we ready to Go?
Adam Dudczak
 
CSharp for Unity Day2
CSharp for Unity Day2CSharp for Unity Day2
CSharp for Unity Day2
Duong Thanh
 
Testing CLI tools with Go
Testing CLI tools with GoTesting CLI tools with Go
Testing CLI tools with Go
Ricardo Gerardi
 
Lab manual operating system [cs 502 rgpv] (usefulsearch.org) (useful search)
Lab manual operating system [cs 502 rgpv] (usefulsearch.org)  (useful search)Lab manual operating system [cs 502 rgpv] (usefulsearch.org)  (useful search)
Lab manual operating system [cs 502 rgpv] (usefulsearch.org) (useful search)
Make Mannan
 
Continuations
ContinuationsContinuations
Continuationsopenbala
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
Kandarp Tiwari
 
Go: It's Not Just For Google
Go: It's Not Just For GoogleGo: It's Not Just For Google
Go: It's Not Just For Google
Eleanor McHugh
 
Stack prgs
Stack prgsStack prgs
Stack prgs
Ssankett Negi
 
The Ring programming language version 1.5.2 book - Part 75 of 181
The Ring programming language version 1.5.2 book - Part 75 of 181The Ring programming language version 1.5.2 book - Part 75 of 181
The Ring programming language version 1.5.2 book - Part 75 of 181
Mahmoud Samir Fayed
 
C programming
C programmingC programming
C programming
Samsil Arefin
 
Aho-Corasick string matching algorithm
Aho-Corasick string matching algorithmAho-Corasick string matching algorithm
Aho-Corasick string matching algorithmTakatoshi Kondo
 
The Ring programming language version 1.5.3 book - Part 89 of 184
The Ring programming language version 1.5.3 book - Part 89 of 184The Ring programming language version 1.5.3 book - Part 89 of 184
The Ring programming language version 1.5.3 book - Part 89 of 184
Mahmoud Samir Fayed
 
Cn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshanCn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshanriturajj
 

What's hot (20)

The Ring programming language version 1.9 book - Part 91 of 210
The Ring programming language version 1.9 book - Part 91 of 210The Ring programming language version 1.9 book - Part 91 of 210
The Ring programming language version 1.9 book - Part 91 of 210
 
Os lab 1st mid
Os lab 1st midOs lab 1st mid
Os lab 1st mid
 
Time-driven applications
Time-driven applicationsTime-driven applications
Time-driven applications
 
20070329 Java Programing Tips
20070329 Java Programing Tips20070329 Java Programing Tips
20070329 Java Programing Tips
 
Travel management
Travel managementTravel management
Travel management
 
Operating System Lab Manual
Operating System Lab ManualOperating System Lab Manual
Operating System Lab Manual
 
The Ring programming language version 1.5.3 book - Part 88 of 184
The Ring programming language version 1.5.3 book - Part 88 of 184The Ring programming language version 1.5.3 book - Part 88 of 184
The Ring programming language version 1.5.3 book - Part 88 of 184
 
Are we ready to Go?
Are we ready to Go?Are we ready to Go?
Are we ready to Go?
 
CSharp for Unity Day2
CSharp for Unity Day2CSharp for Unity Day2
CSharp for Unity Day2
 
Testing CLI tools with Go
Testing CLI tools with GoTesting CLI tools with Go
Testing CLI tools with Go
 
Lab manual operating system [cs 502 rgpv] (usefulsearch.org) (useful search)
Lab manual operating system [cs 502 rgpv] (usefulsearch.org)  (useful search)Lab manual operating system [cs 502 rgpv] (usefulsearch.org)  (useful search)
Lab manual operating system [cs 502 rgpv] (usefulsearch.org) (useful search)
 
Continuations
ContinuationsContinuations
Continuations
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
 
Go: It's Not Just For Google
Go: It's Not Just For GoogleGo: It's Not Just For Google
Go: It's Not Just For Google
 
Stack prgs
Stack prgsStack prgs
Stack prgs
 
The Ring programming language version 1.5.2 book - Part 75 of 181
The Ring programming language version 1.5.2 book - Part 75 of 181The Ring programming language version 1.5.2 book - Part 75 of 181
The Ring programming language version 1.5.2 book - Part 75 of 181
 
C programming
C programmingC programming
C programming
 
Aho-Corasick string matching algorithm
Aho-Corasick string matching algorithmAho-Corasick string matching algorithm
Aho-Corasick string matching algorithm
 
The Ring programming language version 1.5.3 book - Part 89 of 184
The Ring programming language version 1.5.3 book - Part 89 of 184The Ring programming language version 1.5.3 book - Part 89 of 184
The Ring programming language version 1.5.3 book - Part 89 of 184
 
Cn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshanCn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshan
 

Viewers also liked

2015 Toyota Yaris in Scranton | Scranton Toyota Dealership
2015 Toyota Yaris in Scranton | Scranton Toyota Dealership2015 Toyota Yaris in Scranton | Scranton Toyota Dealership
2015 Toyota Yaris in Scranton | Scranton Toyota Dealership
scranton toyota
 
Google+ Profiles for Investor Relations
Google+ Profiles for Investor RelationsGoogle+ Profiles for Investor Relations
Google+ Profiles for Investor Relations
IR Smartt Inc.
 
My SlideShow
My SlideShowMy SlideShow
My SlideShow
Jeremy_Bridson
 
Good Enough Mother
Good Enough MotherGood Enough Mother
Good Enough Mother
Rene Syler
 
Evaluation proper
Evaluation properEvaluation proper
Evaluation properNicoleTonge
 
this one is the one!! yay!!
this one is the one!! yay!!this one is the one!! yay!!
this one is the one!! yay!!mlutwyche
 
Preliminary task
Preliminary taskPreliminary task
Preliminary taskShamha848
 
《昨年は1万社が合格!》創業時に知っておきたい、経済産業省から700万円の補助金を獲得する方法とは?
《昨年は1万社が合格!》創業時に知っておきたい、経済産業省から700万円の補助金を獲得する方法とは?《昨年は1万社が合格!》創業時に知っておきたい、経済産業省から700万円の補助金を獲得する方法とは?
《昨年は1万社が合格!》創業時に知っておきたい、経済産業省から700万円の補助金を獲得する方法とは?
schoowebcampus
 
EST Summit - Upcoming Projects
EST Summit - Upcoming ProjectsEST Summit - Upcoming Projects
EST Summit - Upcoming Projects
Jazman Barizi
 
Positive thinking attitudes_and_beliefs_final_ppt_29.09.2011
Positive thinking attitudes_and_beliefs_final_ppt_29.09.2011Positive thinking attitudes_and_beliefs_final_ppt_29.09.2011
Positive thinking attitudes_and_beliefs_final_ppt_29.09.2011Pallavi Jagtap
 
CliqTags - Funktioner och fördelar
CliqTags - Funktioner och fördelarCliqTags - Funktioner och fördelar
CliqTags - Funktioner och fördelarCliqTags
 
Datacopter
DatacopterDatacopter
Datacopter
ranganlav
 
Fundraising & event planning
Fundraising & event planningFundraising & event planning
Fundraising & event planning
Joel Natt
 
Strukturtumbuhan bermutu-ipa
Strukturtumbuhan bermutu-ipaStrukturtumbuhan bermutu-ipa
Strukturtumbuhan bermutu-ipaMuhammad Noval
 
Media & Consultant ADSangtao
Media & Consultant ADSangtaoMedia & Consultant ADSangtao
Media & Consultant ADSangtao
Maru Lord
 

Viewers also liked (18)

2015 Toyota Yaris in Scranton | Scranton Toyota Dealership
2015 Toyota Yaris in Scranton | Scranton Toyota Dealership2015 Toyota Yaris in Scranton | Scranton Toyota Dealership
2015 Toyota Yaris in Scranton | Scranton Toyota Dealership
 
Google+ Profiles for Investor Relations
Google+ Profiles for Investor RelationsGoogle+ Profiles for Investor Relations
Google+ Profiles for Investor Relations
 
My SlideShow
My SlideShowMy SlideShow
My SlideShow
 
Good Enough Mother
Good Enough MotherGood Enough Mother
Good Enough Mother
 
Evaluation proper
Evaluation properEvaluation proper
Evaluation proper
 
this one is the one!! yay!!
this one is the one!! yay!!this one is the one!! yay!!
this one is the one!! yay!!
 
Preliminary task
Preliminary taskPreliminary task
Preliminary task
 
《昨年は1万社が合格!》創業時に知っておきたい、経済産業省から700万円の補助金を獲得する方法とは?
《昨年は1万社が合格!》創業時に知っておきたい、経済産業省から700万円の補助金を獲得する方法とは?《昨年は1万社が合格!》創業時に知っておきたい、経済産業省から700万円の補助金を獲得する方法とは?
《昨年は1万社が合格!》創業時に知っておきたい、経済産業省から700万円の補助金を獲得する方法とは?
 
Black List
Black ListBlack List
Black List
 
EST Summit - Upcoming Projects
EST Summit - Upcoming ProjectsEST Summit - Upcoming Projects
EST Summit - Upcoming Projects
 
vega profile
vega profilevega profile
vega profile
 
Positive thinking attitudes_and_beliefs_final_ppt_29.09.2011
Positive thinking attitudes_and_beliefs_final_ppt_29.09.2011Positive thinking attitudes_and_beliefs_final_ppt_29.09.2011
Positive thinking attitudes_and_beliefs_final_ppt_29.09.2011
 
CliqTags - Funktioner och fördelar
CliqTags - Funktioner och fördelarCliqTags - Funktioner och fördelar
CliqTags - Funktioner och fördelar
 
Datacopter
DatacopterDatacopter
Datacopter
 
ใบงานที่6งานคอม
ใบงานที่6งานคอมใบงานที่6งานคอม
ใบงานที่6งานคอม
 
Fundraising & event planning
Fundraising & event planningFundraising & event planning
Fundraising & event planning
 
Strukturtumbuhan bermutu-ipa
Strukturtumbuhan bermutu-ipaStrukturtumbuhan bermutu-ipa
Strukturtumbuhan bermutu-ipa
 
Media & Consultant ADSangtao
Media & Consultant ADSangtaoMedia & Consultant ADSangtao
Media & Consultant ADSangtao
 

Similar to Polynomial addition

Double linked list
Double linked listDouble linked list
Double linked list
raviahuja11
 
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of list
Elavarasi K
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
Lakshmi Sarvani Videla
 
Single linked list
Single linked listSingle linked list
Single linked list
Sayantan Sur
 
Double linked list
Double linked listDouble linked list
Double linked list
Sayantan Sur
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
Lakshmi Sarvani Videla
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
Circular linked list
Circular linked listCircular linked list
Circular linked list
Sayantan Sur
 
Datastructures asignment
Datastructures asignmentDatastructures asignment
Datastructures asignmentsreekanth3dce
 
Linked list without animation
Linked list without animationLinked list without animation
Linked list without animation
Lovelyn Rose
 
Linked list
Linked listLinked list
Linked list
Lovelyn Rose
 
public static class LinkedDequeT implements DequeADTT{    priv.pdf
public static class LinkedDequeT implements DequeADTT{    priv.pdfpublic static class LinkedDequeT implements DequeADTT{    priv.pdf
public static class LinkedDequeT implements DequeADTT{    priv.pdf
amaresh6333
 
Потоки в перле изнутри
Потоки в перле изнутриПотоки в перле изнутри
Потоки в перле изнутри
Ilya Zelenchuk
 
stack.pptx
stack.pptxstack.pptx
stack.pptx
MeghaKulkarni27
 
Java 7 JUG Summer Camp
Java 7 JUG Summer CampJava 7 JUG Summer Camp
Java 7 JUG Summer Camp
julien.ponge
 

Similar to Polynomial addition (20)

Double linked list
Double linked listDouble linked list
Double linked list
 
Binary tree
Binary treeBinary tree
Binary tree
 
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of list
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
Single linked list
Single linked listSingle linked list
Single linked list
 
Double linked list
Double linked listDouble linked list
Double linked list
 
week-4x
week-4xweek-4x
week-4x
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 
Datastructures asignment
Datastructures asignmentDatastructures asignment
Datastructures asignment
 
Linked list without animation
Linked list without animationLinked list without animation
Linked list without animation
 
Linked list
Linked listLinked list
Linked list
 
public static class LinkedDequeT implements DequeADTT{    priv.pdf
public static class LinkedDequeT implements DequeADTT{    priv.pdfpublic static class LinkedDequeT implements DequeADTT{    priv.pdf
public static class LinkedDequeT implements DequeADTT{    priv.pdf
 
Потоки в перле изнутри
Потоки в перле изнутриПотоки в перле изнутри
Потоки в перле изнутри
 
งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์
 
stack.pptx
stack.pptxstack.pptx
stack.pptx
 
week-14x
week-14xweek-14x
week-14x
 
Java 7 JUG Summer Camp
Java 7 JUG Summer CampJava 7 JUG Summer Camp
Java 7 JUG Summer Camp
 
JAVA SE 7
JAVA SE 7JAVA SE 7
JAVA SE 7
 

Recently uploaded

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 

Recently uploaded (20)

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 

Polynomial addition

  • 1. Polynomial Addition #include<stdio.h> #include<conio.h> #include<process.h> #include<alloc.h> void CreatePolyFirst(); void CreatePolySecond(); //Function Protypes void AddPoly(); void Attach(int, int, struct node *); struct node { int coef , exp; //Structure Definition struct node *next; } *first=NULL, *second=NULL, *New=NULL, *temp1=NULL, *temp2=NULL, *result=NULL, *temp3=NULL;
  • 2. Polynomial Addition void main() { int ch; clrscr(); do { printf("n***MENU***"); printf("n1.Create 1st Polynomial”); printf(“n2.Create 2nd Polynomial”); printf("n3.Add Both Polynomial printf(”n4.Exit"); printf("nPlease Enter the Choice..."); scanf("%d",&ch);
  • 3. Polynomial Addition switch(ch) { case 1: CreatePolyFirst(); break; case 2: CreatePolySecond(); break; case 3: AddPoly(); break; case 4: exit(0); default: printf("n Invalid Choice..."); } }while(ch!=4); getch(); }
  • 4. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} New first = NULL
  • 5. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); 5 if(New->exp==0) if(New->coef==0) break; break; }} New 5 first = NULL
  • 6. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} New 5 first = NULL
  • 7. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); 2 printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} New 5 2 first = NULL
  • 8. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} New 5 2 first = NULL
  • 9. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} New, 5 2 first
  • 10. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} New, 5 2 first temp1
  • 11. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} New, 5 2 first temp1
  • 12. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} first 5 2 New temp1
  • 13. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); 8 if(New->exp==0) if(New->coef==0) break; break; }} first 5 2 New 8 temp1
  • 14. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} first 5 2 New 8 temp1
  • 15. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); 1 printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} first 5 2 New 8 1 temp1
  • 16. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} first 5 2 New 8 1 temp1
  • 17. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} first 5 2 New 8 1 temp1
  • 18. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} first 5 2 New 8 1 temp1
  • 19. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} first 5 2 New 8 1 temp1
  • 20. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} 5 2 8 1 New first temp1
  • 21. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); 4 if(New->exp==0) if(New->coef==0) break; break; }} 5 2 8 1 New 4 first temp1
  • 22. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} 5 2 8 1 New 4 first temp1
  • 23. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); 0 printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} 5 2 8 1 New 4 0 first temp1
  • 24. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} 5 2 8 1 New 4 0 first temp1
  • 25. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} 5 2 8 1 New 4 0 first temp1
  • 26. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} 5 2 8 1 New 4 0 first temp1
  • 27. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} 5 2 8 1 New 4 0 first temp1
  • 28. void CreatePolyFirst() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(first==NULL) Order...n"); { printf("nFor end enter 0.n"); first=New; temp1=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp1->next=New; New->next=NULL; temp1=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} first 5 2 8 1 4 0
  • 29. void CreatePolySecond() printf("nEnter the Exponent..."); { scanf("%d",&New->exp); printf("nEnter Polynomial in Descending if(Second==NULL) Order...n"); { printf("nFor end enter 0.n"); second=New; temp2=New; while(1) } { else New=(struct node *) malloc (sizeof { (struct node)); temp2->next=New; New->next=NULL; temp2=New; printf("nEnter the Coefficient..."); } scanf("%d",&New->coef); if(New->exp==0) if(New->coef==0) break; break; }} second 4 4 7 2 2 1
  • 30. void AddPoly() New->next=NULL; { if(p->exp==q->exp) struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) . { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 second 4 4 7 2 2 1
  • 31. void AddPoly() New->next=NULL; { if(p->exp==q->exp) struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q
  • 32. void AddPoly() New->next=NULL; { if(p->exp==q->exp) struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) . { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q
  • 33. void AddPoly() New->next=NULL; { if(p->exp==q->exp) 2==4 struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q New
  • 34. void AddPoly() New->next=NULL; { if(p->exp==q->exp) struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) 2<4 while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q New
  • 35. void AddPoly() New->next=NULL; { if(p->exp==q->exp) struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q New
  • 36. void Attach(int c,int e,struct node *d) . else { (4, 4, New) { temp3->next=d; if(result==NULL) temp3=d; { temp3->coef=c; result=d; temp3->exp=e; temp3=New; } temp3->coef=c; } temp3->exp=e; } first 5 2 8 1 4 0 p 4 4 7 2 2 1 second q New result= NULL
  • 37. void Attach(int c,int e,struct node *d) . else { (4, 4, New) { temp3->next=d; if(result==NULL) temp3=d; { temp3->coef=c; result=d; temp3->exp=e; temp3=New; } temp3->coef=c; } temp3->exp=e; } first 5 2 8 1 4 0 p 4 4 7 2 2 1 second q New result, temp3
  • 38. void Attach(int c,int e,struct node *d) . else { (4, 4, New) { temp3->next=d; if(result==NULL) temp3=d; { temp3->coef=c; result=d; temp3->exp=e; temp3=New; } temp3->coef=c; } temp3->exp=e; } first 5 2 8 1 4 0 p 4 4 7 2 2 1 second q New 4 4 result, temp3
  • 39. void AddPoly() New->next=NULL; { if(p->exp==q->exp) struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q res, 4 4 temp3
  • 40. void AddPoly() New->next=NULL; { if(p->exp==q->exp) struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q res, 4 4 New temp3
  • 41. void AddPoly() New->next=NULL; { if(p->exp==q->exp) 2==2 struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q res, 4 4 New temp3
  • 42. void AddPoly() New->next=NULL; { if(p->exp==q->exp) struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; x= 5+7=12 { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q res, 4 4 New temp3
  • 43. void AddPoly() New->next=NULL; { if(p->exp==q->exp) struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q res, 4 4 12 2 temp3
  • 44. void AddPoly() New->next=NULL; { if(p->exp==q->exp) struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q res, 4 4 12 2 temp3
  • 45. void AddPoly() New->next=NULL; { if(p->exp==q->exp) struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q res 4 4 12 2 New temp3
  • 46. void AddPoly() New->next=NULL; { if(p->exp==q->exp) 1==1 struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q res 4 4 12 2 New temp3
  • 47. void AddPoly() New->next=NULL; { if(p->exp==q->exp) struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; x=8+2=10 { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q res 4 4 12 2 New temp3
  • 48. void AddPoly() New->next=NULL; { if(p->exp==q->exp) struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q res 4 4 12 2 10 1 temp3
  • 49. void AddPoly() New->next=NULL; { if(p->exp==q->exp) struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q=NULL res 4 4 12 2 10 1 temp3
  • 50. void AddPoly() New->next=NULL; { if(p->exp==q->exp) struct node *p,*q,*r; int x; { if(first==NULL || second==NULL) x=p->coef+q->coef; { if(x!=0) printf("nYour First or Second Attach(x,p->exp,New); Polynomial is Invalid..."); p=p->next; return; q=q->next; } } p=first; q=second; else if(p->exp<q->exp) while(p!=NULL && q!=NULL) { { Attach(q->coef,q->exp,New); New=(struct node *) malloc (sizeof q=q->next; (struct node)); } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q=NULL res 4 4 12 2 10 1 temp3
  • 51. else printf("nAddition of Both Polynomial...n"); { if(result==NULL) Attach(p->coef, p->exp, New); { p=p->next; printf("0"); return; }} } while(p!=NULL) while(result!=NULL) { { Attach(p->coef,p->exp,p); printf("%dx^%d",New->coef,New->exp); p=p->next;} if(result->next!=NULL) while(q!=NULL) printf(" + "); { New=New->next; Attach(p->coef,p->exp,q); } q=q->next;} } first 5 2 8 1 4 0 p second 4 4 7 2 2 1 q=NULL res 4 4 12 2 10 1 temp3
  • 52. else printf("nAddition of Both Polynomial...n"); { if(result==NULL) Attach(p->coef, p->exp, New); { p=p->next; printf("0"); return; }} } while(p!=NULL) while(result!=NULL) { { Attach(p->coef,p->exp,p); printf("%dx^%d",New->coef,New->exp); p=p->next;} if(result->next!=NULL) while(q!=NULL) printf(" + "); { New=New->next; Attach(p->coef,p->exp,q); } q=q->next;} } first 5 2 8 1 4 0 p=NULL second 4 4 7 2 2 1 q=NULL res 4 4 12 2 10 1 4 0 temp3
  • 53. else printf("nAddition of Both Polynomial...n"); { if(result==NULL) Attach(p->coef, p->exp, New); { p=p->next; printf("0"); return; }} } while(p!=NULL) while(result!=NULL) { { Attach(p->coef,p->exp,p); printf("%dx^%d",New->coef,New->exp); p=p->next;} if(result->next!=NULL) while(q!=NULL) printf(" + "); { New=New->next; Attach(p->coef,p->exp,q); } q=q->next;} } first 5 2 8 1 4 0 p=NULL second 4 4 7 2 2 1 q=NULL res 4 4 12 2 10 1 4 0
  • 54. else printf("nAddition of Both Polynomialn"); { if(result==NULL) Attach(p->coef, p->exp, New); { p=p->next; printf("0"); return; }} } while(p!=NULL) while(result!=NULL) { { Attach(p->coef,p->exp,p); printf("%dx^%d",New->coef,New- p=p->next;} >exp); while(q!=NULL) if(result->next!=NULL) { printf(" + "); Attach(p->coef,p->exp,q); New=New->next; q=q->next;} } } res 4 4 12 2 10 1 4 0 res - > 4x^4 + 12x^2 + 10x^1 + 4