google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: C program for multiplication of two polynomial in data structure

Monday, April 6, 2015

C program for multiplication of two polynomial in data structure

#include<stdio.h>
#include<conio.h>
void main()
{
 int a[10],b[10],c[10];
 int i,j,n,k,power,coeff;
 clrscr();
 for(i=0;i<10;i++)
 {
  a[i]=0;
  b[i]=0;
  c[i]=0;
 }
 printf("\n first polynomel");
 printf("\n enter number of terms=");
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
  printf("\n enter coefficient=");
  scanf("%d",&coeff);
  printf("\n enter power");
  scanf("%d",&power);
  a[power]=coeff;
 }
 printf("\n second polynomel");
 printf("\n enter number of terms=");
 scanf("%d",&k);
 for(i=0;i<k;i++)
 {
  printf("\n enter coefficient=");
  scanf("%d",&coeff);
  printf("\n enter power");
  scanf("%d",&power);
  b[power]=coeff;
 }
 for(i=9;i>=0;i--)
 {
  if(a[i]!=0)
  {
   for(j=9;j>=0;j--)
   {
    if(b[j]!=0)
    {
     c[i+j]=c[i+j]+a[i]*b[j];
    }
   }
  }
 }
 printf("\n our results is=");
 for(i=9;i>=0;i--)
 {
  if(c[i]!=0)
  {
   if(i!=0)
   {
    printf("%dx^%d+",c[i],i);
   }
   else
   {
    printf("%dx^%d",c[i],i);
   }
  }
 }
 getch();
}

शिव भोलेनाथ स्तुति

 जय शिवशंकर, जय गंगाधर, करुणा-कर करतार हरे,   जय कैलाशी, जय अविनाशी, सुखराशि, सुख-सार हरे जय शशि-शेखर, जय डमरू-धर जय-जय प्रेमागार हरे,   जय ...