Im new to C++ and want to write a quick little program. What I want it to do is ask for two numbers, then it will multiply the two numbers. If the number is greater than 9000, the program will close, but if it is less than 9000, I want it to display the answer. Here is what I have:
#include "stdafx.h"
#include <iostream>
using namespace std;
int main ()
{
double diabeetus1 = 0.0;
double diabeetus2 = 0.0;
double diabeetusavg = (diabeetus1 * diabeetus2);
cout << "Enter First Number";
cin >> diabeetus1;
cout << "Enter the second number";
cin >> diabeetus2;
if ( diabeetusavg > 9000 )
{
cout<<("Thats over 9,000! This program will now terminate");
}
else if ( diabeetusavg < 9000 )
{
cout<<(diabeetus1 * diabeetus2);
}
system("pause");
return 0;
}
For some reason, it doesnt do exactly what I want and skips my if than statement.
Idd, just move the the intitialization of diabeetusavg below the two input values, and it should run fine. otherwise you multiply 0 with 0, and will always get the same outcome, regardless of input.