Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

All input data must be stored in a file input.txt . All output data must be stored in a file output.txt . All output must

All input data must be stored in a file input.txt.

All output data must be stored in a file output.txt.

All output must also be printed to the screen.

Using C++, code the following program. The input file contains several pairs of integers of arbitrary length. Data is terminated by a line containing -1 only. Your program must read two integers from the file. The built-in data types such as int and long have a maximum fixed length so variables of these types cannot be used to input the integers from the file. Each large integer must be read from the file and stored in a singly linked list, one digit per node. The least significant digit of the large integer must be stored at the top of the list and the most significant digit must be stored at the end of the list. Assume that each large integer has at most 50 digits. After creating the linked lists for the two large integers, you must find the sum of the integers. This sum must be stored in another linked list. Finally, your program must display the two large integers, exactly as they were read from the file as well as their sum.

Example 1:

Input:

Large Integer 1: 957994954495949457454

Large Integer 2: 774874754744875847484

Your output should be similar to this:

957994954495949457454 +

774874754744875847484

======================

1732869709240825304938

======================

Example 2:

Input:

Large Integer 1: 80485080443358

Large Integer 2: 4849850549686868696

Your output should be similar to this:

80485080443358 +

4849850549686868696

===================

4849931034767312054

===================

Sample Input.txt

957994954495949457454 774874754744875847484

80485080443358 4849850549686868696

99999999 11111111111111111876333

777777678 9999999999

5555555555 44444444444444444465

-1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions

Question

Design a health and safety policy.

Answered: 1 week ago