Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

An integer can be represented by a linked list with one digit in each node. The

ID: 3661140 • Letter: A

Question

An integer can be represented by a linked list with one digit in each node. The least significant digit in this representation is in the first node of the list. This allows for integers of virtually any size. The nodes are of the following type: struct digit { int Value; // a digit value, 0-9 digit* Next; }; typedef digit* ptrType; Develop an ADT named number with the following operations for unlimited-digit numbers. In the following descriptions, number refers to an object of your ADT. M, N and O are all of type number. The sample usage for each operation shows how it might be used, although you can make your operations work differently. Increment: A method that increases the value of a number by 1. Sample usage: N.Increment(); Note that you cannot necessarily just change the last digit of the number; adding 1 to 1999, for example, requires changing all four digits to get 2000, and adding 1 to 9 requires making a new digit to get 10. Hint: You should allow for three possibilities in your function regarding the initial value for N. a. N is NULL b. N is not NULL, and the value in the first node is 0..8 c. N is not NULL, and the value in the first node is 9 Copy: A method that copies one number to another. Note that you cannot just copy one pointer to another

Explanation / Answer

#include #include #include #define MAX 10001 struct integer { int* digits; int size; }; struct integer* add(struct integer* one, struct integer *two); void print(struct integer* number); void print_op(struct integer* op1, struct integer* op2,struct integer* tempwer,char op); struct integer* convert_integer(char* word); void free_struct(struct integer* thisint); struct integer* multiply(struct integer *p, struct integer *q); int main() { FILE* ifp = fopen("bigint.txt", "r"); int loop, numcases; fscanf(ifp, "%d", &numcases); // Go through each case. for (loop=1; loop
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote