Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

 

/* the program accepts two polynomials as a input & prints the resultant polynomial because of the addition of input polynomials*/

#include

void main()

{

int poly1[6][2],poly2[6][2],term1,term2,match,proceed,i,j;

printf("Enter the number of terms in first polynomial. They must be less than 6:\n");

scanf("%d",&term1);

printf("Enter the number of terms in the second polynomial. They must be less than 6:\n");

scanf("%d",&term2);

printf("Enter the exponent and coefficient of every term of the first polynomial:\n");

for(i=0;i

{scanf("%d %d",&poly1[i][0],&poly1[i][1]);

}

printf("Enter the exponent and coefficient of every term of the second polynomial:\n");

for(i=0;i

{scanf("%d %d",&poly2[i][0],&poly2[i][1]);

}

printf("The resulting polynomial because of the addition of the input two polynomials:\n");

for(i=0;i

{

match=0;

for(j=0;j

{ if (match==0)

if(poly1[i][1]==poly2[j][1])

{ printf("%d   %d\n",(poly1[i][0]+poly2[j][0]), poly1[i][1]);

match=1;

}

}

}

for(i=0;i

{

 proceed=1;

for(j=0;j

{  if(proceed==1) if(poly1[i][1]!=poly2[j][1]) proceed=1;

else

proceed=0;

}

if (proceed==1)

printf("%d %d\n",poly1[i][0],poly1[i][1]);

}

for(i=0;i

{  proceed=1;

for(j=0;j

{  if(proceed==1) if(poly2[i][1]!=poly1[j][1]) proceed=1;

else

proceed=0;

}

if (proceed==1)

printf("%d %d",poly2[i][0],poly2[i][1]);

}

}

Output:

Enter the number of terms in first polynomial. They must be less than 6: 5. Enter the number of terms in the second polynomial .They must be less than 6: 4. Enter the coefficient & exponent of each of term of the first polynomial:

1 2

2 4

3 6

1 8

5 7

Enter the coefficient & exponent of every term of the second polynomial:

5 2

6 9

3 6

5 7

The resultant polynomial because of the addition of the input two polynomials:

6 2

6 6

10 7

2 4

1 8

6 9

The program prompted initially for number of terms of the two polynomials. Then, this prompted for the entry of terms of the 2 polynomials one after another. At first, this adds the coefficients of the corresponding terms of both the polynomials whose exponents are the similar. Then, this prints the terms of the primary polynomial who does not contain corresponding terms in the second polynomial along with the same exponent. Lastly, it prints the terms of the second polynomial that does not contain corresponding terms in the first polynomial.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9617549

Have any Question?


Related Questions in Computer Engineering

A compute the sumnbsps1nbsp 1 2 3 nbsp nbsp 9999 the sum

(a) Compute the sum S1 = 1 + 2 + 3 + . . . + 9999 (the sum of all integers from 1 to 9999). Do not use a program. (b) Compute the sum S2 = 1+3+5+...+9999 (the sum of all odd integers from 1 to 9999). Do not use a program ...

The question is asking how to do it in linuxa scientist ran

The question is asking how to do it in Linux. A scientist ran an experiment that generated data that accumulated in a sequence of files: data1, data2, data3, data4 and data5. He wants to know how many lines of data he ha ...

Rocket motors are tested by restraining them on the ground

Rocket motors are tested by restraining them on the ground, firing them with a known amount of propellant, and measuring the thrust over time. A typical curve is shown below. The total impulse is the integral of the thru ...

Looping structures can be very helpful when coding an

Looping structures can be very helpful when coding an application. These are designed for iterative statements that need to happen multiple times. There are several looping structures you can utilize in C++, For, While a ...

How much of the opposing side should you share in a

How much of the opposing side should you share in a presentation to a multiple-perspective audience, and what techniques would you use?

Whats the difference between a bigfile tablespace and a

What's the difference between a Bigfile tablespace and a Smallfile tablespace? Explain which you would use for your database and why.

Sketch out a simple network management system for ndas what

Sketch out a simple network management system for NDAS. What software and hardware support would you recommend? Be sure you justify the information items collected and reported for this system, as well as your software a ...

A for which hypervisors does kali linux offer custom

a. For which hypervisors does Kali Linux offer custom images? What tools must be added to a VirtualBox Kali Linux VM to provide proper integration with the host machine? b. What hypervisor comes already installed in Kali ...

Program in cit is often times advantageous to be able to

*Program in C* It is often times advantageous to be able to transfer data between two arrays. Need a help with program (transfer.c) that add a range (by start index and end index) of numbers from array #1 to array #2 at ...

One of the 5 halogens which are diatomic has the fastest

One of the 5 halogens (which are diatomic) has the fastest root mean square velocity at STP. Calculate this velocity in meters per second.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As