Question: write a C funciton called Integer50 *big50Add(Integer50 *p, Integer50 *q); Description: Return a pointer to a new, dynamically allocated Integer50 struct that contains the result

write a C funciton called Integer50 *big50Add(Integer50 *p, Integer50 *q); 

Description: Return a pointer to a new, dynamically allocated Integer50 struct that contains the result of adding the 50 digit integers represented by p and q.

Special Notes: If a NULL pointer is passed to this function, simply return NULL. If any dy- namic memory allocation functions fail within this function, also return NULL, but be care- ful to avoid memory leaks when you do so.

Hint: Before adding two huge integers, you will want to create an array to store the result. Re- member that all integers in this problem are 50 digits long. In the event that the most sig- nificant digits (MSD) result in a carry, the carry will be ignored. For example, if the MSD of the two inputs are 9 and 7, the resultant MSD will be 6 with a carry of 1 for the MSD + 1 digit. (9 + 7 = 16, therefore 6 is the MSD and the 1 is ignored.)

Returns: A pointer to the newly allocated Integer50 struct, or NULL in the special cases men- tioned above.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!