tempCodeRunnerFile.cpp:1:9: fatal error: iostream.h: No such file or directory #include<iostream.h> ^~~~~~~~~~~ ~ compilation terminated.
I wrote this code but I am getting the error. How can I get rid of this.
HERE IS THE PROGRAM IN C++:
#include<iostream.h>
#include<conio.h>
class poly
{
struct node
{
int coeff,deg;
node (lin;
};
node *start,*last;
int size;
public:
poly()
{
start=NULL;
}
void getpoly();
poly operator+(poly);
void display();
};
void poly::getpoly()
{
cout<<"\n\tenter the size:";
cin>>size;
for(int i=1;i<=size;i++)
{
node *temp=new node;
cout<<"\n\tenter the coeffcint:";
cin>>temp->coeff;
cout<<"\n\tenter the degree:";
cin>>temp->deg;
temp->link=NULL;
if(start==NULL)
start=temp;
else
last->link=temp;
last=temp;
}
}
poly poly::operator+(poly p)
{
{
poly temp;
int k=0;
node *i,*j;
i=start;
j=p.start;
while((i!=NULL)&&(j!=NULL))
{
node*t=new node;
t->link=NULL;
if(i->deg==j->deg)
{
k++;
t->coeff=i->coeff+j->coeff;
t->deg=i->deg;
i=j->link;
j=j->link;
}
else if(i->deg>j->deg)
{
t->coeff=i->coeff;
t->deg=i->deg;
i=i->link;
k++;
}
else
{
t->coeff=j->coeff;
t->deg=j->deg;
j=j->link;
k++;
}
if(temp.start==NULL)
temp.start=t;
}
while(i!=NULL)
{
node *t=new node;
t->coeff=i->coeff;
t->deg=i->deg;
t->link=NULL;
temp.last->link=t;
temp.last=t;
i=i->link;
k++;
}
while(j!=NULL)
{
node *t=new node;
t->coeff=j->coeff;
t->deg=j->coeff;
t->link=NULL;
temp.last->link=t;
temp.last=t;
j=j->link;
k++;
}
temp.size=k;
return(temp);
}
void poly::display()
{
for(node *i=start;i!=NULL;i=i->link)
{
if((i->coeff>0)&&(i!=start))
cout<<"+";
cout<<i->coeff<<"X"<<"^"i->deg;
}
}
void main()
{
poly a,b,c;
clrscr();
cout<<"\n\tINPUT";
cout<<"\n\t***";
a.getpoly();
b.getpoly();
c=a+b;
cout<<endl;
cout<<"\n\tOUTPUT";
cout<<"\n\t****";
cout<<"\n\tfirst polynomial:";
a.display();
cout<<endl;
cout<<"\n\tsecond polynomial:";
b.display();
cout<<endl;
cout<<"\n\taddition polynomial:";
c.diplay();
getch();
}
Input:
enter the size:2
enter the coeffcint:5
enter the degree:2
enter the coeffcint:7
enter the degree:1
enter the size:2
enter the coeffcint:3
enter the degree:2
enter the coeffcint:3
enter the degree:1
Output:
first polynomial:5X^2+7X^1
second polynomial:3X^2+3X^1
addition polynomial:8x^2+10X^1