1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97

// Includes
#include <cstdlib>
#include <iostream>
#include <cctype>
// Use standard namespace
using namespace std;
// Prototypes
int add(int n1, int n2);
int sub(int n1, int n2);
// Main
int main(void)
{
int x, y;
char y_or_n;
do
{
cout << "Enter a 1 for runs past the 50 yardline/n";
cout << "Enter a 2 for runs inside the 50 yardline/n";
cin >> num;
if (num < 1  num > 3)
cout << "Sorry, you put in the wrong number!" << endl;
} while (num <1  num >2);
if (num == 1)
{do
{
cout << "Yardline of reception: ";
cin >> x;
cout << "Yardline of tackle: ";
cin >> y;
//cout << x << " + " << y << " = " << add(x,y) << endl;
//cout << 100 << "  " << x+y << " = " << sub(100,x+y) << endl;
cout << sub(100,x+y) << "_" << "Yard Return" << endl;
//cout << x << "  " << y << " = " << sub(x, y) << endl;
cout << "Go again (Y/n)? ";
cin >> y_or_n;
cout << endl;
} } while (tolower(y_or_n) != 'n');
else
{
cout << "What yardline did the run start?/n";
cin >> x;
cout << "What yardline was the runner tackled?/n";
cin >> y;
//cout << x << "  " << y << " = " << sub(x,y) << endl;
}
// Return to OS
return 0;
}
// add /////////////////////////////////////////////////////
int add(int n1, int n2)
{
int carry, sum;
// Find out which bits will result in a carry.
// Those bits will affect the bits directly to
// the left, so we shall shift one bit.
carry = (n1 & n2) << 1;
// In digital electronics, an XOR gate is also known
// as a quarter adder. Basically an addition is performed
// on each individual bit, and the carry is discarded.
//
// All I'm doing here is applying the same concept.
sum = n1 ^ n2;
// If any bits match in position, then perform the
// addition on the current sum and the results of
// the carry.
if (sum & carry)
{
return add(sum, carry);
}
// Return the sum.
else
{
return sum ^ carry;
}
}
// sub /////////////////////////////////////////////////////
int sub(int n1, int n2)
{
// In binary arithmetic, subtraction is simply adding the
// two's complement. The two's complement is simply one
// added to the one's complement.
return add(n1, add(~n2, 1));
}
 