#include
#include
int a[10][2];
int b[10][2];
int c[10][2];
//void inp(int);
main()
{
int n,i=0,j=0,k=0;
clrscr();
printf("\n\tEnter the First Equation\n");
while(1)
{
printf("Enter the Co-efficient--->");
scanf("%d",&a[i][0]);
printf("Enter the Exponent------>");
scanf("%d",&a[i][1]);
if(a[i][1]==0)
break;
i++;
}
i++;
a[i][1]=-1;
printf("\n\tEnter the Second eq:\n");
while(1)
{
printf("Enter the Co-efficient--->");
scanf("%d",&b[j][0]);
printf("Enter the Exponent------>");
scanf("%d",&b[j][1]);
if(b[j][1]==0)
break;
j++;
}
j++;
b[i][1]=-1;
i=0;j=0;k=0;
while(a[i][1]!=-1&&b[j][1]!=-1)
{
if(a[i][1]==b[j][1])
{
c[k][0]=a[i][0]+b[j][0];
c[k][1]=a[i][1];
i++;j++;k++;
}
if(a[i][1]>b[j][1])
{
c[k][1]=a[i][1];
c[k][0]=a[i][0];
i++;k++;
}
if(a[i][1] {
c[k][1]=b[j][1];
c[k][0]=b[j][0];
j++;k++;
}
}
while(a[i][1]!=-1)
{
c[k][0]=a[i][0];
c[k][1]=a[i][1];
k++;
i++;
}
while(b[j][1]!=-1)
{
c[k][0]=b[i][0];
c[k][1]=b[i][1];
k++;
j++;
}
c[k][1]=-1;
clrscr();
i=0;j=0;k=0;
printf("THE FIRST EQ:--> ");
while(a[i][1]!=-1)
{
printf("->%d^%d ",a[i][0],a[i][1]);
i++;
}
printf("\nTHE SECOND EQ:--> ");
while(b[j][1]!=-1)
{
printf("->%d^%d ",b[j][0],b[j][1]);
j++;
}
printf("\nTHE RESULT EQ:--> ");
while(c[k][1]!=-1)
{
printf("->%d^%d ",c[k][0],c[k][1]);
k++;
}
getch();
}
No comments:
Post a Comment