Question

Write an algorithm and a program in ‘C’ language for addition of two Polynomials

13 Sep 2024
Answer :
Word Count : 1165

### Algorithm for Addition of Two Polynomials

1. Input Representation:
   - Represent polynomials as arrays of coefficients. For a polynomial \( P(x) = a_nx^n + a_{n-1}x^{n-1} + \dots + a_1x + a_0 \), use an array `P[]` where `P[i]` stores the coefficient of \( x^i \).

2. Input the Polynomials:
   - Take two polynomials of the form:
     - Polynomial 1: \( P1(x) = a_nx^n + a_{n-1}x^{n-1} + \dots + a_1x + a_0 \)
     - Polynomial 2: \( P2(x) = b_nx^n + b_{n-1}x^{n-1} + \dots + b_1x + b_0 \)
   - Each polynomial is stored in an array, with indices corresponding to the powers of \( x \).

3. Adjust for Different Polynomial Sizes:
   - Determine the degree of both polynomials (highest power of \( x \)) and make both arrays of equal length by padding the shorter array with zeros.
   
4. Add the Polynomials:
   - Initialize a new array `sum[]` of the same size as the largest polynomial.
   - For each corresponding index in the polynomials, add the coefficients of the same power of \( x \) and store the result in the `sum[]` array.

5. Output the Result:
   - Traverse the `sum[]` array and print the result in polynomial form, skipping any terms where the coefficient is zero.

### C Program for Addition of Two Polynomials

```c
#include <stdio.h>
#include <stdlib.h>

// Function to add two polynomials
void addPolynomials(int *poly1, int *poly2, int *sumPoly, int size1, int size2) {
    // Find the maximum degree of the two polynomials
    int maxSize = (size1 > size2) ? size1 : __________ ___ _________ ___ ___ ____ _________ __________.
_______ ___ ____ _____ _____ _______ _____ ____ _______.
___ _____ ______ ___ _____ _________ _________.
_______ ____ _________ ____ __________ ____ _________ ___ ___ _________.
_____ ______ _____ ________ ________ __________ ____ _______ ________ _______ ______.
___ ___ ________ ______ __________ _____ ____ _____ _________.
___ ___ __________ _________ _________ ______ _______ _______ ______ ______ _________ _________.
___ _________ ________ _____ ___ _________ ___ ___ ____ _________ __________.
__________ ___ ______ _____ ____ ___ __________ ______.
_________ ________ __________ ________ _____ ____ ________ _________ ____ _______ ____.
_________ ________ _____ _______ __________ ________ ______ ___ ______ ____ ______.
________ __________ _________ _____ ______ ________ ______.
_________ ______ _______ ___ ___ ____ ________ ______ ___ ________.
______ ___ ________ _______ _____ _______ ______ ____ _________ ___ ___ ______.
____ ____ _______ _____ _____ ___ ________ ______.
____ _____ ________ ___ ____ _____ __________ __________ ________ ________ ____.
_______ ______ ______ __________ ________ ________ ___ __________ _______ _________ ______ __________.
_________ _____ ________ ___ ________ __________ ________ ______ ______ _______.
_________ _______ ______ ___ ____ _______ _______ ________ ________ _____ ________.
__________ ________ ________ _____ _________ _________ __________ ___.
_________ _______ _________ _______ ___ __________.
_____ ______ ____ _____ ________ _____ ___ ____ _______ ___ _________.
______ _____ _____ ______ ______ ___ ___.
___ __________ __________ _____ ______ __________ ______ ____ _____ _________ ____ _________.
__________ ___ __________ _____ ______.
___ ______ ___ ________ _____ ______ ______.
________ ___ __________ ___ _________ ______ ________ ____ __________.
________ ________ _____ ________ _____.
_______ ________ ____ _______ _________ _________ ________ ___ __________ ___ ___.
____ __________ ________ ____ _______ ________ ________ ______ __________ __________.
_________ ____ _____ ___ ________ ___ __________ ________ _________.
_________ _________ _______ ________ ______ ____ ___.
______ ________ _____ ____ ______ ________ ____ _____ ___.
_________ _________ __________ _______ ___ _______ ______ ___.
__________ ________ ____ _______ _________ ________ ______ __________.
_____ ________ ___ ____ ___ ____ ______.
_____ ________ ____ __________ __________.
___ ___ _________ ___ ______ ________ ___ ___ _______.
__________ ___ ______ ______ _________ _______ _______ __________ ____.
_____ ___ __________ ___ _____ ___ ________ __________ ____ ___.
____ _______ __________ __________ ___ __________ _______ ___ _______ ________ ______ ______.
_______ _________ ______ ________ ____ ____ _____ _________.
________ ________ ____ ____ _____ ____ ____ _____ ______.
_________ ________ _______ _______ _____ _______ ____.
____ ________ ___ ____ __________ __________.
____ _____ _____ _________ ______ ________ __________ _________ _______ _______ _________.
_________ _________ __________ ____ ____ _________ ___.
___ _____ _________ __________ __________ ________.
_________ _______ __________ ______ ______ _____ ___.
__________ ___ ___ _________ ________ _______ __________ __________ ___ ______.
_____ _____ _______ _________ ___ ________ _________ ___ _____ ___ ______ ____.
_______ _________ __________ _____ __________ ____ _______ __________ ____ ________ _____ ______.
_________ ______ _________ ____ __________ _________ ________ _______ ______.
_____ _________ ___ ________ _____ ______ ___.
_____ _____ ______ _________ _____ ____ ______ ___ ______ _______.
_______ ___ ______ _________ ________ ______ ________ _________ _____ _________.
_________ ____ ______ ______ ___ ______ _______ _________ _____ ____ _______ _____.
_______ ________ __________ __________ _____ _______ _____ ____ ______ _________.
_________ ____ ___ _______ _______ ______ ______ _______ ____ _____ ______.
____ ____ ________ _______ ________ ____ _____ ________ ___ ________ __________ _________.
____ ______ _______ _____ _________.
____ _______ __________ _____ ___.
___ ____ ____ __________ ______ ________ ______ _________ _____ _______ __________.
_________ __________ _______ _______ _______.
______ ________ __________ _______ ______ ____.
__________ _____ ____ _______ __________ _________.
___ ___ ________ ______ __________ ______.
________ _____ __________ ____ ______ ________ ______ __________ _______ ___.
_______ ___ ____ ____ ___.
______ _____ ________ ________ _____ __________.
_______ ____ ____ _______ __________.
_____ __________ _________ _____ ___ ________ ___.
_____ ____ ____ _________ _______ ________ _________ _____ ___ _________ _______.
_____ ____ ______ ____ _______ ____ __________.
____ _______ _________ ________ ____.
____ ____ ____ _________ _______ ________ ______ __________ ____ ___ _____ ____.
_____ ____ _________ __________ _____ ____ _________.
____ _________ ________ ______ __________ _________ ___ _________ ___ ______ _____ _________.
_____ ___ ________ ____ ____ _____ ________ ____ _________ ________ ____ ___.
________ ______ ________ _________ _____ __________ ____ ______ ________ _____ ____.
___ _____ _____ __________ ___ _______ __________ ________ ___ ______ _______.
__________ ____ _________ ________ ______ ____ ________.
________ __________ _________ ____ ________ _________ ____ __________.
___ _________ ________ ______ __________ ________.
_________ ____ _________ __________ ____ ___ ________ _________ _______ _______ _____.
_____ _________ _____ _____ _______ ___ ______ _______ _____ _________ _____ _________.
_____ ________ _________ ________ _______ _______ __________ _____ __________ __________.
_____ ______ __________ _________ _________ ___ ________ _______ ____ ________ _____.
______ _________ _______ _________ ________.
_________ ______ _________ _________ _______ _______ ______ _____ ____ ________.
________ ___ ______ _________ ________ _______ _______ ___.
____ _________ _________ ________ ___ _________ _____ _______.
____ _______ ______ _____ __________ ______ ______.
____ _____ ____ _____ ____ _________ ________ _________ _______.
__________ ___ ______ ____ _____ ________.
______ _______ ______ __________ ______ ____ __________.
______ _____ ________ ______ ________ ___ __________ ___ _______ ______.
_________ ________ _________ _________ _________ __________ ________ ______ _______ ___ ___.
________ ____ ________ _____ ________.
_________ _______ __________ _________ _______ ____ _____ _________ _________ _________.
Get Full Answer on WhatsApp

IGNOU NEWS
Assignment Submission Last Date Extended Till 30 June 2026 Click Here★★★IGNOU June 2026 TEE Date Sheet Released Click Here★★★
Top
📞
Call Support Instant phone assistance Write an algorithm and a program in ‘C’ language for addit
🟢
WhatsApp Chat Fast live messaging
Email Us Business enquiries & support