Hello, I am making a program where you are entering 2 numbers which should be product AND sum of other 2 numbers. The program then outputs what are the other 2 numbers. For example if I enter sum 13 and product 22 the program will output 2 and 11. But if I enter -13 (!) and 22 the program will not do anything. I changed the code that if it doesnt do anything then it should subtract decrement num1 instead of incrementing it (i.e. in the first way I increment number starting from 0 and now I decrement it). But this way doesnt work eaither. THis is my code
#include <iostream>
using namespace std;
int main()
{
while(true) {
bool b = false;
float sum;
float product;
cout << "\nEnter sum: ";
cin >> sum;
cout << "\nEnter product: ";
cin >> product;
float num1 = 0;
float num2;
int j = 100000;
while((b == false) && (j>0)) {
num2 = sum- num1;
if((product / num1) != num2 )
{
b = false;
num1++;
num2 = sum - num1;
}
else {
cout << "\nNumber one is " << num1 << " and number two is " << num2;
b = true;
}
j--;
}
if (j<0) {
b = false;
num1 = 0;
j = 100000;
while((b == false) && (j>0)) {
num2 = sum - num1;
if((product / num1) != num2 )
{
b = false;
num1--;
}
else {
cout << "\nNumber one is " << num1 << " and number two is " << num2;
b = true;
}
j--;
}
}
}
return 0;
}
What should I do to make it work with -13(sum) and 22 (product)? It should say -2 and -11 for output.