//The program does simple calculations like add and sub
#include <iostream>
#include <cstdlib>
using std::cout;
using std::cin;
int dosum(int a,int b);
int dosub(int a,int b);
int main()
{
char ans;
int a,b;
cout<<"What type of operation do wish to perform? enter a for additions or s for subtraction\n";
cin>>ans;
if(ans!='a'&& ans!='s')
{
cout<<"You entered the wrong answer for the opration to be performed\n";
exit(1); /*the program exits if the user enters a wrong specification for operation*/
}
cout<<"Input the two numbers\n";
cin>>a, cin>>b;
if (ans=='a'||ans=='A')
{
cout<<"The sum of the two numbers entered is "<<dosum(a,b)<<" \n";
}
else if(ans=='s'||ans=='S')
{
cout<<"The difference of the two numbers is "<<dosub(a,b)<<" \n";
}
return 0;
}
int dosum(int a,int b)
{
return a+b;
}
int dosub(int a,int b)
{
return a-b;
}
Ly9UaGUgcHJvZ3JhbSBkb2VzIHNpbXBsZSBjYWxjdWxhdGlvbnMgbGlrZSBhZGQgYW5kIHN1YgojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDxjc3RkbGliPgp1c2luZyBzdGQ6OmNvdXQ7CnVzaW5nIHN0ZDo6Y2luOwoKaW50IGRvc3VtKGludCBhLGludCBiKTsKaW50IGRvc3ViKGludCBhLGludCBiKTsKCgppbnQgbWFpbigpCnsKY2hhciBhbnM7CmludCBhLGI7CiAgICAKY291dDw8IldoYXQgdHlwZSBvZiBvcGVyYXRpb24gZG8gd2lzaCB0byBwZXJmb3JtPyBlbnRlciBhIGZvciBhZGRpdGlvbnMgb3IgcyBmb3Igc3VidHJhY3Rpb25cbiI7CmNpbj4+YW5zOwogICAgaWYoYW5zIT0nYScmJiBhbnMhPSdzJykKICAgIHsKY291dDw8IllvdSBlbnRlcmVkIHRoZSB3cm9uZyBhbnN3ZXIgZm9yIHRoZSBvcHJhdGlvbiB0byBiZSBwZXJmb3JtZWRcbiI7CiAgICAgICAgCiAgICBleGl0KDEpOyAgIC8qdGhlIHByb2dyYW0gZXhpdHMgaWYgdGhlIHVzZXIgZW50ZXJzIGEgd3Jvb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