Question: C++ Write a function that adds two non-negative integers represented as strings, returning the result as a string. The function must use the following signature:

C++

Write a function that adds two non-negative integers represented as strings, returning the result as a string.

The function must use the following signature:

string add(const string& num1, const string& num2) 

The values num1 and num2 can represent arbitrarily long integers, so all the calculations must be done without using integer types (except for calculating each digit.)

There is no need to check for or deal with strings that do not represent non-negative integers.

Restrictions

In your submitted work (any of the functions you write) you should not print out anything to cout or cerr, and you should not use terminal input cin.

You may only include the libraries iostream and string. No other includes are permitted.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!