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

Monday, April 6, 2015

C program in data structure for polynomial subtraction

#include<stdio.h>
#include<conio.h>
void main()
{
 int a[10],b[10],c[10];
 int n,k,i,p,coeff;
 clrscr();
 for(i=0;i<10;i++)
 {
  a[i]=0;
  b[i]=0;
  c[i]=0;
 }
 printf("\n first polynomial");
 printf("\n enter number of terms=");
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
  printf("\n enter power & coefficient=");
  scanf("%d%d",&p,&coeff);
  a[p]=coeff;
 }
 printf("\n second polynomial");
 printf("\n enter number of terms=");
 scanf("%d",&k);
 for(i=0;i<k;i++)
 {
  printf("\n enter power & coefficient=");
  scanf("%d%d",&p,&coeff);
  b[p]=coeff;
 }
 for(i=0;i<10;i++)
 {
  c[i]=a[i]-b[i];
 }
 printf("\n polynomial subtraction 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();
}

अच्छे विचार करे विचार

  पहचान की नुमाईश, जरा कम करें... जहाँ भी "मैं" लिखा है, उसे "हम" करें... हमारी "इच्छाओं" से ज़्यादा "सुन...