diff options
| author | Arthur Spears <[email protected]> | 2024-04-15 22:16:47 -0700 |
|---|---|---|
| committer | Arthur Spears <[email protected]> | 2024-04-15 22:16:49 -0700 |
| commit | a4ab91ea896528c57467798e5f7aba36f0c3227f (patch) | |
| tree | b89f01fe38bee15e2e3f966539f2ab4f4ec24bcd /CST 126/Homework 1/main.cpp | |
| parent | add deadline (diff) | |
| download | archived-homework-1-arthurtspears-a4ab91ea896528c57467798e5f7aba36f0c3227f.tar.xz archived-homework-1-arthurtspears-a4ab91ea896528c57467798e5f7aba36f0c3227f.zip | |
all work up until inclass practice
Diffstat (limited to 'CST 126/Homework 1/main.cpp')
| -rw-r--r-- | CST 126/Homework 1/main.cpp | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/CST 126/Homework 1/main.cpp b/CST 126/Homework 1/main.cpp index 398e580..b4c91fc 100644 --- a/CST 126/Homework 1/main.cpp +++ b/CST 126/Homework 1/main.cpp @@ -1,8 +1,70 @@ // Name: Arthur Spears // Class: CST 126 // Date: 3/31/24 -// Assignment: Homework +// Assignment: Homework 1 + +#include <iostream> +#include "helpers.hpp" +#include "menu.hpp" +#include <bitset> + +using std::cout; +using std::endl; + +struct DailyTemperature +{ + int highTemp{}; + int lowTemp{}; +}; + +enum DayOfTheWeek +{ + Sunday = 0, + Monday, + Tuesday, + Wednesday, + Thursday, + Friday, + Saturday = 6 +}; + +enum Month +{ + January = 1, + February, + March, + April, + May, + June, + July, + August, + September, + October, + November, + December +}; + +struct Date +{ + Month month; + uint8_t day; + uint16_t year; +}; + +union FloatIntUnion +{ + float intFloat; + uint32_t uInt; +}; int main() { + FloatIntUnion floatIntUnion {}; + floatIntUnion.intFloat = 1.2345f; + + std::cout << "Float: " << floatIntUnion.intFloat << std::endl; + std::cout << "Binary representation: " << std::bitset<32>(static_cast<uint32_t>(floatIntUnion.intFloat)) << std::endl; + std::cout << "As Int: " << floatIntUnion.uInt << std::endl; + std::cout << "Binary representation: " << std::bitset<32>(floatIntUnion.uInt) << std::endl; + return 0; -}
\ No newline at end of file +} |