Ok, this is my second program ever (and first post), the first one was the calculator, so I would appreciate and criticism. What do you guys think?
EDIT: BTW: AntiRTFM I wanted to say I truly appreciate you helping us out and teaching us C++.
- Code: Select all
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int a;
int b;
// I know I should have used more easily identifiable variable names.
//I'll make sure it doesn't become a habit.
cout << "Weclome to the Stat-0-Tron 5000\n";
cout << "Enter the first number you are interested in: ";
cin >> a;
cout << "\nNow enter the second number you have in mind: ";
cin >> b;
//Greater than, less than, or equal to
if (a != b)
{
cout << a << " is not equal to " << b;
cout << " because... ";
if (a < b)
cout << a << " is less than " << b << endl;
else
cout << a << " is greater than " << b << endl;
}
else
cout << a << " is equal to " << b << endl;
//evens or odds?
if (a % 2 == 0)
cout << a << " is an even number\n";
else
cout << a << " is an odd number\n";
if (b % 2 == 0)
cout << b << " is an even number\n";
else
cout << b << " is an odd number\n";
//positive, negative
if (a < 0)
cout << a << " is a negative number.\n";
else
cout << a << " is a positive number.\n";
if (b < 0)
cout << b << " is a negative number.\n";
else
cout << b << " is a positive number.\n";
//subtraction
if (a > b)
cout << "The difference between these numbers is: " << (a - b) << endl;
else
cout << "The difference between these numbers is: " << (b - a) << endl;
//division
float y = a;
float z = b;
cout << a << " Divided by " << b << " equals: " << (y / z) << endl;
cout << b << " Divided by " << a << " equals: " << (z / y) << endl;
cout << "Press the 'any' key and Enter to exit.\n";
//Thats a joke, btw.
char f;
cin >> f;
return 0;
}