Use of Function padd() in c ?

This function adds the node to the resultant list (i.e. p3) in the descending order of the exponents of the polynomial.

To begin with we initialize a structure pointer temp with a value p, where p is pointer to the first node of the resultant list. Its value would be NULL when called for the first time.

Initially a condition is checked whether the resultant list is empty or not. If it is so then we need to add the first node. Hence memory is allocated for the new node and the value of coefficient and exponent is assigned to the coefficient and exponent part of the new node, temp which holds a NULL value to begin with is stored in the link part of the resultant new node.

When padd( ) is called to add the second node we need to compare the exponent value of the new node with that of the first node. If the exponent value of the new node is greater than the exponent value of the first node in the resultant list, then the new node is made the first node.

If both the above two conditions are false then the resultant list is traversed for searching the proper position where the new node is to be inserted. If the exponent of the same order already exists .

Related Links :

No comments:

Post a Comment

If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE

More Useful Topics...


History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming

My 1st Program...

void main ()
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();

Next Step...


void main ()
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();