I am trying to have the user input 2 binary numbers and then adding and multiplying them. The problem that I am having is after I call the first function from the class it exits the program. Any help would be greatly appreciated.
#include "binNum.h" //obtain prototype definitions
#include <iostream>
usingnamespace std;
binNum::binNum()
{
i = 0;
carry = 0;
result = 0;
}
void binNum::numbers()
{
cout << "Enter a 4 bit binary number entering only 0's and 1's: ";
for ( i=0; i < 5; i++)
{
cin>> num[i];
}
cout << "Enter another 4 bit binary number entering only 0's and 1's: ";
for (i = 0; i < 5; i++)
{
cin>> num2[i];
}
}
int binNum::addition(int i)
{
for(i = 0; i < 32; ++i) {
int a = (num[4] >> i) & 1;
int b = (num2[4] >> i) & 1;
result |= ((a ^ b) ^ carry) << i;
carry = (a & b) | (b & carry) | (carry & a);
}
return result;
}
binNum::~binNum() // Destructor function definition
{ cout << "press enter to exit";
}