Find Jobs
Hire Freelancers

C - array/stacks large numbers

$30-60 USD

In Progress
Posted over 19 years ago

$30-60 USD

Paid on delivery
One possible solution to implement the addition operation is to store the large numbers as strings of numerals, store the numbers corresponding to these numerals in two stacks, and then perform addition by popping numbers from the stacks. The pseudocode for this algorithm is as follows: 1. Read the first number as a string of characters. 2. Store the digit corresponding to each character on a stack (for example, each stack element could hold an int, which would correspond to one character in the input string). The order of pushing the digits on the stack should be such that the least significant digit appears at the top of the stack. 3. Repeat steps 1 and 2 for the second number. 4. Create a stack for the result. 5. set carry = 0. 5. While at least one of the stack is not empty Pop a digit from each non-empty stack and add them. sum = num1 + num2 + carry Push the unit part of sum on the result stack. Save carry. 6. When one of the stacks is empty, push the digits from the other stack on to the result stack, taking care of the carry. 7. If both stacks get empty at the same time, push the carry on the result stack if it is not zero. 7. Pop numbers from the result stack and display them ( as character string). ## Deliverables The project will be limited to developing software for carrying out addition and multiplication of two very large numbers. The basic process will be similar to the way you have been doing multiplication in elementary school ( multiplying by one digit at a time). You can draw upon the idea presented above for addition of two numbers to carry out multiplication. Pop one digit from second stack, and multiply all the digits of first stack with this, and save the result in a temporary stack. Add this to the result stack. **_User Input Specification_** 1. The user will enter a valid input file name. 2. The input file will contain the two character strings representing the two positive numbers. 3. It is specified that the result of the multiplication will not be longer than 100 digits. 4. On prompting the user will enter the output file name. **_Data Processing_** Develop functions for - reading data from file, and writing onto a file . (Convert each character read from the file into the corresponding digit, when building up the stacks. ) - ARRAY BASED push and pop routines which can operate on any one of the stacks at a time. - addition, multiplication and display of results. **_Output Specification_** 1. Save the results of addition and multiplication on two lines in that order, on the output file specified by the user. 2. Display the results on the screen. **_Sample Input File _** *[login to view URL]*. 3523011938638144 619232 **_Sample Output Samples_** Here is a sample output for the file *[login to view URL]*. Enter the name of the file containing the grades **[login to view URL]** Enter the name of the output file to hold the result: **[login to view URL]** Result of addition: 3523011939257376 Result of multiplication: 2181561728786775185408 1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. 2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables): a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment. b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request. 3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement). ## Platform Source code in just plain old C
Project ID: 3380001

About the project

5 proposals
Remote project
Active 20 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
See private message.
$34 USD in 2 days
5.0 (54 reviews)
5.2
5.2
5 freelancers are bidding on average $43 USD for this job
User Avatar
See private message.
$42.50 USD in 2 days
5.0 (93 reviews)
6.0
6.0
User Avatar
See private message.
$51 USD in 2 days
5.0 (100 reviews)
5.6
5.6
User Avatar
See private message.
$42.50 USD in 2 days
5.0 (51 reviews)
5.3
5.3
User Avatar
See private message.
$42.50 USD in 2 days
4.9 (91 reviews)
5.3
5.3

About the client

Flag of UNITED STATES
United States
5.0
3
Member since Oct 6, 2004

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.