"polynomial operations using c++" Code Answer's
You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "polynomial operations using c++" answered properly. Developers are finding an appropriate answer about polynomial operations using c++ related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like polynomial operations using c++. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on polynomial operations using c++.
polynomial operations using c++
//Addition of Two Polynomial
#include <iostream.h>
#include <iomanip.h>
#include <conio.h>
struct poly{
int coeff;
int pow;
poly *next;
};
class add2poly
{
poly *poly1, *poly2, *poly3;
public:
add2poly(){poly1=poly2=poly3=NULL;}
void addpoly();
void display();
};
void add2poly :: addpoly(){
int i,p;
poly *newl=NULL,*end=NULL;
cout<<"Enter highest power for x\n";
cin>>p;
//Read first poly
cout<<"\nFirst Polynomial\n";
for(i=p;i>=0;i--)
{
newl=new poly;
newl->pow=p;
cout<<"Enter Co-efficient for degree"<<i<<":: ";
cin>>newl->coeff;
newl->next=NULL;
if(poly1==NULL)
poly1=newl;
else
end->next=newl;
end=newl;
}
//Read Second poly
cout<<"\n\nSecond Polynomial\n";
end=NULL;
for(i=p;i>=0;i--)
{
newl=new poly;
newl->pow=p;
cout<<"Enter Co-efficient for degree"<<i<<":: ";
cin>>newl->coeff;
newl->next=NULL;
if(poly2==NULL)
poly2=newl;
else
end->next=newl;
end=newl;
}
//Addition Logic
poly *p1=poly1,*p2=poly2;
end=NULL;
while(p1 !=NULL && p2!=NULL){
if(p1->pow == p2->pow){
newl=new poly;
newl->pow=p--;
newl->coeff=p1->coeff + p2->coeff;
newl->next=NULL;
if(poly3==NULL)
poly3=newl;
else
end->next=newl;
end=newl;
}
p1=p1->next;
p2=p2->next;
}
}
void add2poly :: display(){
poly *t=poly3;
cout<<"\n\nAnswer after addition is : ";
while(t!=NULL){
cout.setf(ios::showpos);
cout<<t->coeff;
cout.unsetf(ios::showpos);
cout<<"X"<<t->pow;
t=t->next;
}
}
void main(){
clrscr();
add2poly obj;
obj.addpoly();
obj.display();
getch();
}
Source: www.dailyfreecode.com
All those coders who are working on the C++ based application and are stuck on polynomial operations using c++ can get a collection of related answers to their query. Programmers need to enter their query on polynomial operations using c++ related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about polynomial operations using c++ for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of polynomial operations using c++ while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "polynomial operations using c++". Visit this developer's friendly online web community, CodeProZone, and get your queries like polynomial operations using c++ resolved professionally and stay updated to the latest C++ updates.