1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#include <iostream>
using namespace std;
typedef unsigned short int USHORT; // This makes it so I don't have to type UNSIGNED INT infront of every int value to define it's type
typedef signed short int SHORT; // This makes it so I don't have to type SIGNED INT just like the first case
const USHORT MyAge = 24; /* Defining the variables used by the program. That they are constantly the same throughout(const), that they are Unsigned short (USHORT),
what the symbolic reference is (MyAge), and finally what the variable's value is (24)*/
const USHORT DaysYr = 365;
const USHORT SchoolYr = 17;
void Textfunction() // This is a simple text function which can be called at any point in the main() but typing "Textfunction()"
{
cout << "This is the text function\n";
}
int main()
{
cout << "First line of text directly outputted to the console\n";
cout << (MyAge * DaysYr) << "\n"; // notice how the (<< "\n";) is used to make sure the next line is indeed printed as the NEXT line instead of the same line. Do this when created arimetical lines.
Textfunction(); // This is the first call to the function
for (int i = 32; i<128; i++)
cout << (char) i;/* This is a "for" loop. I declare that "i" is REPRESENTING the integer (int) value of 32.
I then declare that "i" will enumerate itself up to 128. I then declare that it is to count up by ones (++). This is how CHAR is done and symbols based on the ASCII ledger are created */
cout << "Hopefully the characters on the above line worked properly \n";
Textfunction();
cout << "USHORT caps at 65,535 and ULONG caps at 4,294,967,295 \n"; /* Just so you know how many intergers these two common variable definions use.
Signed versions split the cap in half and go into the negative. */
enum Days { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; // This is an enumerated constant. Each day is assigned a value starting from 0. So in this case it is 0-6 for the days.
Days today; // This declares that symbolic input to choose which of the values you want to use
today = Sunday; // This is were you choose your value that you want your program to use from the enumerated list(Sunday)
if (today == Sunday || today == Saturday) // This declares that "if today is saturday or sunday, then the output will be as follows,
cout << "Gotta love the weekends!\n";
else // This declares that if the choosen value is anything else (other than Saturday or Sunday) then the output will be as follows.
cout << "Back to work :(\n"; // This is the end of the enumerated constant sequence.
Textfunction();
/* These next twos lines of code are needed in this compiler specifically in order to keep the program onscreen and running instead of a flash on and off. */
char response;
cin >> response;
return 0;
}
|