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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started