Write a C/C++ program that accepts two integers (each of them could be positive, negative, or zero) as input and generates as output the result of their addition. Both integers are entered by the user and saved into two string variables, named S_ENT1 and S_ENT2, respectively. Similarly, the result of their addition should be saved into a third string variable, S_ENT3. An integer is a sequence of characters including only digits, namely ‘0’, …, ‘9’. Thus, both integers should be checked so that no other character could be entered. The implementation of this adder should be as structured as possible.
Teachers give the stupidest assignments sometimes. I understand they want you to know how to move around between types at run time, but this is just a dumb way to teach it. Anyway, have you actually done anything yet? This isn't a site where we do your homework for you, at least not free. If you wanna send 10 dollars to my paypal I'll gladly write this up for you.
#include <iostream>
#include <ostringstream>
using namespace std;
int main()
{
int a,b,result;
string S_ENT1, S_ENT2;
ostringstream convert;
cout<<"First number: ";
cin >> S_ENT1;
a = atoi (S_ENT1);
while(a==NULL)
{
cout<<"The number you entered is not an integer, try again: ";
cin>> S_ENT1;
a= atoi (S_ENT1);
}
cout<<"Second number: ";
cin >> S_ENT2;
b = atoi (S_ENT2);
while(b==NULL)
{
cout<<"The number you entered is not an integer, try again: ";
cin>> S_ENT2;
b= atoi (S_ENT2);
}