Hi,

please help me with this program that i am writing. i am writing a program to create a polynomial. i set the values, but whenever, i debug it, i get this:

4x^2 + 0X^1 + 0x^0 + which do not correspond to the values that i set it to. it's not reading the second and 3rd coefficients.

i expect to get 4x^2 + 5x + 6.

please help me . also, how do i get rid of the plus that comes after the polynomial.

```
#include<iostream>
using namespace std;
//A class to handle a list node
class Lnode{
public:
Lnode();
Lnode(int);
int data;
Lnode *next;//This is the pointer to the next node
};
Lnode::Lnode(){
data = 0;
next = NULL;
}
Lnode::Lnode(int d){
data = d;
next = NULL;
}
class LList{
public:
LList();
LList(int);
int getSize();
void print();
void printP();
void add(LList L1);
void set(int, int);
private:
void addToF(int);//adding a number to the front of the list.
Lnode *head, *tail, *current;//a list has two pointers, head and tail.
//both are pointing to the already defined List node.
int size, degree;
};
//Constructor Definition
LList::LList(){
size = 0;
head = tail = NULL;//initially, there is nothing. none of them exist.
}
LList::LList(int n){
head=tail=NULL;
size = n;
for(int i=size; i>0; i--)
addToF(0);
}
int LList::getSize(){
return size;//to know the size of the list
}
void LList::addToF(int d){
Lnode *nnode = new Lnode(d);//pointer to the list node
nnode -> next=head;
head = nnode;
if(tail==NULL)
//size++;
}
void LList::print(){
Lnode *current = head;
while( current!= NULL)
{
cout<<current->data<<" ";
current = current->next;
}
}
void LList::printP(){
current = head;
degree = size-1;
while( current != NULL)
{
cout<<current->data<<"x^"<<degree<<" "<<"+";
current = current->next;
degree--;
}
}
void LList::set(int c, int val)
{
int i = size;
current = head;
if(i==(c+1))
{
current->data = val;
//cout<<current->data;
}
else
{
current = current->next;
i--;
}
}
/*void LList::add(LList L1){
//Lnode *newnode = new Lnode;
//int data;
Lnode *tempL2;
Lnode *tempL1;
tempL2 = tail;
tempL1 = L1.tail;
tempL2->data = tempL1->data + tempL2->data;
tempL1 = tempL1->next;
tempL2 = tempL2->next;
//return newnode->data;
}*/
//Driver Main Program
void main(){
LList a(3);//a is an object
//cout<<a.getSize()<<endl;
//cout<<" "<<endl;
a.set(2, 4);
a.set(1, 5);
a.set(0, 6);
a.printP();
cout<<endl;
//a.printx();
cout<<endl;
/*LList b(3);
//b.print();
//b.Sizen(3);
b.set(2, 4);
b.set(1, 6);
b.set(0, 9);
b.printP();
cout<<endl;
//b.add(a);
//cout<<endl;*/
}
```

thank you very much for your help.