Examples of C part 57 multiply 2 polynomial
Program :
Output:
Enter number of terms in Polynomial 1
6
Enter number of terms in Polynomial 2
9
Enter Elements of Polynomial 1
Enter x^0 Co-Efficient of Polynomial 1
1
Enter x^1 Co-Efficient of Polynomial 1
2
Enter x^2 Co-Efficient of Polynomial 1
3
Enter x^3 Co-Efficient of Polynomial 1
4
Enter x^4 Co-Efficient of Polynomial 1
5
Enter x^5 Co-Efficient of Polynomial 1
6
Enter Elements of Polynomial 2
Enter x^0 Co-Efficient of Polynomial 2
1
Enter x^1 Co-Efficient of Polynomial 2
2
Enter x^2 Co-Efficient of Polynomial 2
3
Enter x^3 Co-Efficient of Polynomial 2
4
Enter x^4 Co-Efficient of Polynomial 2
5
Enter x^5 Co-Efficient of Polynomial 2
6
Enter x^6 Co-Efficient of Polynomial 2
7
Enter x^7 Co-Efficient of Polynomial 2
8
Enter x^8 Co-Efficient of Polynomial 2
9
54 x^13 + 93 x^12 + 118 x^11 + 130 x^10 + 130 x^9 + 119 x^8 + 98 x^7 + 77 x^6 + 56 x^5 + 35 x^4 + 20 x^3 + 10 x^2 + 4 x^1 + 1 x^0Explanation:
//Coming Soon..
#include<stdio.h> main() { int i,j,sizePoly1,sizePoly2; printf("Enter number of terms in Polynomial 1\n"); scanf("%d",&sizePoly1); printf("Enter number of terms in Polynomial 2\n"); scanf("%d",&sizePoly2); int a[sizePoly1],b[sizePoly2],prod[sizePoly1+sizePoly2]; printf("Enter Elements of Polynomial 1\n"); for(i=0;i<sizePoly1;i++) { printf("Enter x^%d Co-Efficient of Polynomial 1\n",i); scanf("%d",&a[i]); } printf("Enter Elements of Polynomial 2\n"); for(i=0;i<sizePoly2;i++) { printf("Enter x^%d Co-Efficient of Polynomial 2\n",i); scanf("%d",&b[i]); } for(i=0;i<sizePoly1+sizePoly2;i++) { prod[i]=0; } for(i=0;i<sizePoly1;i++) { for(j=0;j<sizePoly2;j++) { if(a[i]!=0 && b[j]!=0) prod[i+j]+=a[i]*b[j]; } } for(i=sizePoly1+sizePoly2-1;i>=0;i--) { if(prod[i]!=0){ if(i!=0) { printf("%d x^%d + ",prod[i],i); } else { printf("%d x^%d\n",prod[i],i); } } } }
Enter number of terms in Polynomial 1
6
Enter number of terms in Polynomial 2
9
Enter Elements of Polynomial 1
Enter x^0 Co-Efficient of Polynomial 1
1
Enter x^1 Co-Efficient of Polynomial 1
2
Enter x^2 Co-Efficient of Polynomial 1
3
Enter x^3 Co-Efficient of Polynomial 1
4
Enter x^4 Co-Efficient of Polynomial 1
5
Enter x^5 Co-Efficient of Polynomial 1
6
Enter Elements of Polynomial 2
Enter x^0 Co-Efficient of Polynomial 2
1
Enter x^1 Co-Efficient of Polynomial 2
2
Enter x^2 Co-Efficient of Polynomial 2
3
Enter x^3 Co-Efficient of Polynomial 2
4
Enter x^4 Co-Efficient of Polynomial 2
5
Enter x^5 Co-Efficient of Polynomial 2
6
Enter x^6 Co-Efficient of Polynomial 2
7
Enter x^7 Co-Efficient of Polynomial 2
8
Enter x^8 Co-Efficient of Polynomial 2
9
54 x^13 + 93 x^12 + 118 x^11 + 130 x^10 + 130 x^9 + 119 x^8 + 98 x^7 + 77 x^6 + 56 x^5 + 35 x^4 + 20 x^3 + 10 x^2 + 4 x^1 + 1 x^0Explanation:
//Coming Soon..