Ok so I'm reading the Programming: Principles and Practice using C++ and Im stuck in Drill 4 part 5. It says:
Change the program so that it writes out the "numbers are almost equal"
after writing out which is the larger and the smaller if the two numbers
differ by less than 1.0/10000000
I'm using an If statement for it... I just need know what the formula is to check 2 numbers that were entered by person if they land within the range specified above. so then I can cout << "numbers are almost equal" << endl;
I couldn't get that to work.... here is what I have so far... u just need to get it to work with what I have here... please excuse my not so pretty code.
#include <iostream>
int main()
{
using namespace std;
double inputone;
double inputtwo;
char flag = '|';
cout << "Enter integers and an '|' to terminate program: ";
while (cin >> inputone >> inputtwo)
{
cout << "Your input was " << inputone << " " << inputtwo << "\n";
if (inputone < inputtwo)
cout << "the smaller value is: " << inputone << "\n"
<< "the larger value is: " << inputtwo << "\n"
<< "\nEnter integers and an '|' to terminate program: \n";
else if (inputone > inputtwo)
cout << "the smaller value is: " << inputtwo << "\n"
<< "the larger value is: " << inputone << "\n"
<< "\nEnter integers and an '|' to terminate program: \n";
else if (inputone = inputtwo)
cout << "the numbers are equal\n"
<< "\nEnter integers and an '|' to terminate program: \n";
}
cout << "\nYou entered " << flag << "... so the program will terminate.\n";