diff options
| author | austinlujan <[email protected]> | 2024-03-06 07:08:00 -0800 |
|---|---|---|
| committer | austinlujan <[email protected]> | 2024-03-06 07:08:00 -0800 |
| commit | 06e9752597a3d39d2f121514ef1d6d298e27318f (patch) | |
| tree | a97d18f126d81337f91df5261e401d661e60847d | |
| parent | update (diff) | |
| download | hello-world-austinlujan-06e9752597a3d39d2f121514ef1d6d298e27318f.tar.xz hello-world-austinlujan-06e9752597a3d39d2f121514ef1d6d298e27318f.zip | |
| -rw-r--r-- | Hello World/Hello World/Program.cpp | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/Hello World/Hello World/Program.cpp b/Hello World/Hello World/Program.cpp index 191d39d..db7bf79 100644 --- a/Hello World/Hello World/Program.cpp +++ b/Hello World/Hello World/Program.cpp @@ -1,23 +1,62 @@ // Name: Austin Lujan // Date: 1/22/24 // Class: CST116 -// Assignment: Assignemnt +// Assignment: Homework 1 #include <iostream> using namespace std; -int main() -{ - cout << "hello world " << endl; +// Declare three integer variables +int var1, var2, var3; - int number; +// Declare const integer 1024 +const int constant = 1024; - cout << "enter a number and press enter: "; +// Enum declaration +enum Color { RED, GREEN, BLUE }; - cin >> number; +// Union declaration +union Data { + int intValue; + float floatValue; + char charValue; +}; + +// Struct declaration containing the enum and union +struct MyStruct { + Color color; + Data data; +}; + +// Typedef of the struct +typedef struct MyStruct MyTypedefStruct; + +int main() { + // Take three integer inputs with prompts + cout << "Enter three integers separated by spaces: "; + cin >> var1 >> var2 >> var3; + + // Calculate sum and multiplication + int sum = var1 + var2 + var3; + int multiply = var1 * var2 * var3; + + // Output sum and multiplication values + cout << "Sum of the three variables: " << sum << endl; + cout << "Multiplication of the three variables: " << multiply << endl; + + // Output differences between sum/mult and constant + cout << "Difference between the sum and the constant: " << sum - constant << endl; + cout << "Difference between the multiplication and the constant: " << multiply - constant << endl; + + // Test enum and union + MyTypedefStruct myStruct; + myStruct.color = GREEN; + myStruct.data.intValue = 10; + + // Output enum and union values + cout << "Enum value: " << myStruct.color << endl; + cout << "Union value: " << myStruct.data.intValue << endl; - cout << "the number you entered is: " << number << endl; - return 0; }
\ No newline at end of file |