Sale!

COMP2000 Assignment 2 Large Numbers solved

Original price was: $35.00.Current price is: $35.00. $21.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

Name of program: bignum.c

Numbers stored in int or long int variables are restricted in size. You are required to write a program to handle the addition of very large integers.
The digits of an integer are stored in a linked list.

Data consists of “commands”, one per line. Valid commands are:

A This command is followed by two integers. The integers are first stored in linked lists and their sum is calculated by manipulating the lists, creating a new list for the sum. Print their sum as follows:

234321 + 87954323 = 88188644

The function for printing an integer is given a pointer to the linked list representation. The integer must be printed in normal order without changing the given list in any way.

B This command is also followed by two integers. The first integer must be stored in an ordinary integer variable (assume the number is small enough) and the second must be stored in a linked list. Add the first to the second, creating a new list for the sum. Print the sum as above.

You may assume that all data given are valid.
Sample input:

A 234321 87954323
B 376 4895979842308
B 99 5432198763452345678765
A 12345678987654321 67890123454321987