In C++ the largest int value is 2147483647. Some real world problems require num
ID: 3575218 • Letter: I
Question
In C++ the largest int value is 2147483647. Some real world problems require numbers larger than this. Similarly if the sum of two correct integers is larger than 2147483647, the result will be incorrect. One way to store and manipulate large integers is to store each individual digit of the number in a string and then take advantage of the fact that the characters of a string can be individually accessed by using an index value and square brackets. This exercise will involve writing a program that inputs two positive integers of at most, 20 digits and outputs the integer sum of the two input numbers. Your program will be composed of several functions: The main function, which will handle any dialog with the user (requesting input and displaying output). Main will use get Number twice to get two multi-digit numbers and then use add Numbers to add the two numbers. The sum will be another string which will then be displayed by main. A function named get Digit to read a single numeric digit. This function should check to make sure that the input is a digit and not an alphabetic character or another nonnumeric character. Function header: char get Digit(void) A function named get Number to read an entire multi-digit number using get Digit Function header: string get(void) A function named add Numbers which will accept two strings as arguments and return a string containing the sum of the two input strings. Function header: string addNumbers(string a, stringExplanation / Answer
a)
int main()
{
string s1,s2,sum;
s1=getNumber();
s2=getNumber();
sum=addNumbers(s1,s2);
cout<<"Sum of the tw numbers is :"<<sum;
return 0;
}
b)
char getDigit()
{
char ch,d;
cin.get(ch);
if(isdigit(ch))
d=ch;
else
cout<<"pls enter number";
return d;
}
c)
string getNumber()
{
string a;
char ch;
cout << "Please enter a positive integer with no more than " << MAX
<< " digits: ";
for (int i = 0; i < 5; i++)
a[i]=getDigit();
}
d)
string addNumbers(string s1,string s2)//int a[], int size_of_A, int b[], int size_of_B, int sum[], int& size_Sum)
{
string sum;
for(int i = 0; i < s1.length(); i++)
sum[i]=s1[i]+s2[i];
return sum;
}
Please include below code if u put all these together for working
#include <cstdlib>
#include <iostream>
#include <cctype>
using namespace std;
const int MAX = 20;
string getNumber();
char getDigit();
string addNumbers(string s1,string s2);