input of first polynomial is good but during the input for second polynomial while loop terminate please help me ....

void polynomial:: polynomial1()
{
//polynomial *head, *temp, *newnode = NULL;
cout << "Enter number of terms : ";
cin >> num_of_terms;
for (int i = 0; i < num_of_terms; i++)
{
cout << "Enter your coefficient : ";
cin >> coeff;
cout << "Enter your exponent : ";
cin >> expo;
//newnode = new polynomial;
if (newnode == NULL)
{
newnode = new polynomial;
newnode->coeff = coeff;
newnode->expo = expo;
newnode->next = NULL;
head = newnode;
}
else
{
temp = head;
newnode = new polynomial;
while (temp->next != NULL)
{
temp = temp->next;
}
newnode->coeff = coeff;
newnode->expo = expo;
temp->next = newnode;
newnode->next = NULL;
}
}
}
void polynomial::polynomial2()
{

cout << "Enter number of terms : ";
cin >> num_of_terms;
for (int i = 0; i < num_of_terms; i++)
{
cout << "Enter your coefficient : ";
cin >> coeff;
cout << "Enter your exponent : ";
cin >> expo;
//newnode = new polynomial;
if (newnode == NULL)
{
newnode = new polynomial;
newnode->coeff = coeff;
newnode->expo = expo;
newnode->next = NULL;
head1 = newnode;
}
else
{
temp = head1;
newnode = new polynomial;
while (temp->next!=NULL)
{
temp = temp->next;
}
newnode->coeff = coeff;
newnode->expo = expo;
temp->next = newnode;
newnode->next = NULL;
}
}
}
Last edited on
- newnode 0x011f9ff8 {expo=0 coeff=0 next=0x00000000 <NULL> ...} polynomial *

num_of_terms <Unable to read memory>
next <Unable to read memory>
coeff <Unable to read memory>
expo <Unable to read memory>


- this 0x00dcfefc {expo=4 coeff=2 next=0x00000000 <NULL> ...} polynomial *
- next 0x00000000 <NULL> polynomial *
expo <Unable to read memory>
coeff <Unable to read memory>
next <Unable to read memory>
num_of_terms <Unable to read memory>
Topic archived. No new replies allowed.