Shadow Coder
@ShadowCoder0
🖥️ 34-year old on a journey to learn software engineering utilizing C++ | This account will serve as my blog and a way to update and track my progress.
Just finished creating this classic "rock, paper, scissors" game. I did use @grok in helping me to create getRandomChoice() but everything else was my own logic 😂
The exercise asked to write a program using a loop to find how many squares are needed to get 1 billion grains restricting the program to doubling the grains each square, to stop once the billion grains are reached and that at no point we ought to go over 64 squares.
I know this is not much but figuring how to make this program out felt good 😊
I was trying to use if, else if statements for every permutation to try to sort 3 integers inputted by the user but I felt that was too stupid 😅 A quick Google search and I found this faster method with <algorithm> and std::min and std::max from the C++ standard.
I haven't reached any lessons regarding loops yet but I am proud to have figured out how to use them simply like this to validate user input. Perhaps there is a better way to go about validation but this felt like I was hacking the system 🤣
I am not going to lie, the concept of bool functions is throwing me off a little bit. I know this simple program I wrote does not check for valid int inputs from users (have not learned that yet). However, I am proud I made this work adding a bool function.
I found std::string and std::string_view quite complicated. I think I finally got it somewhat down.
I am enjoying learning C++ but sometimes I get into some syntax that just doesn't make sense to me. We can get the size of an object (e.g. int) like so: sizeof(object). Simple! But getting the size of an std::string we have to use the object.length() function 🤕 Then, looking at…
Constant expressions with the constexpr keyword are a powerful feature that allows variables and functions to be computed at compile-time. This allows a boost in program efficiency. To qualify, expressions must rely on constant values, such as literals or const variables with…
The as-if rule in C++ allows compilers to optimize code freely as long as the observable behavior (like output or side effects) remains unchanged. This enables faster execution, like removing unused variables or simplifying loops, without altering what the program does. Compilers…
Learned about constants. Use const for variables that won’t change, like const double pi = 3.14159. Named constants make code clearer and easier to update. They’re defined at declaration and can’t be modified later.
Learned type conversion. Implicit conversions risk data loss or bugs, especially with mixed types. Use static_cast for explicit, safe conversions. It ensures clarity and prevents errors in calculations, making code more reliable and maintainable across different scenarios.
Learned about the basics of chars. The char type stores single characters (e.g., 'a', '7') using 1 byte, based on ASCII. Use single quotes for literals. Chars can be printed as letters or numbers. Escape sequences like '\n' handle special chars.
Learned the basics of if-statements. They run code blocks if a condition is true. Use else for alternatives. Relational operators (e.g., >, ==) create conditions. Nesting ifs allow for complex logic, but I should keep it clear to avoid bugs.
United States Trends
- 1. Northern Lights 46.5K posts
- 2. #Aurora 9,972 posts
- 3. #HazbinHotelSpoilers 2,333 posts
- 4. #chaggie 4,206 posts
- 5. #huskerdust 8,216 posts
- 6. Vaggie 5,388 posts
- 7. #DWTS 53.4K posts
- 8. Carmilla 2,414 posts
- 9. MIND-BLOWING 35.9K posts
- 10. AI-driven Web3 N/A
- 11. H-1B 37.1K posts
- 12. Superb 22.6K posts
- 13. Justin Edwards 2,549 posts
- 14. H1-B 4,284 posts
- 15. Sabonis 6,271 posts
- 16. SPECTACULAR 25.3K posts
- 17. Creighton 2,345 posts
- 18. Wike 222K posts
- 19. Gonzaga 3,015 posts
- 20. Cleto 2,669 posts
Something went wrong.
Something went wrong.