One thing you can do that I find comes up pretty often in C is start using switch statements to avoid code duplication. Because your operators all take 2 numbers, you’ve separated out the input handling into its own block; that alone is a really good insight.
You can take it another step further by making your print statement also, mostly, one block of code, with the only difference being the operation being preformed. By printing “The” followed by using an if-else block — or, again, preferably a switch statement — to both print the operation text, and compute memory, you can print the remainder of the line the same way for every operation.
It may seem nitpicky for such a simple program; but the use case of C is for programs which require tight execution and often contain complex, low-level logic. Reducing complexity whenever possible helps make C more readable, as well as signal when the complexity is necessary.
The same person as Daedskin@lemm.ee and Daedskin@programming.dev
- 0 Posts
- 2 Comments
Joined 5 months ago
Cake day: June 26th, 2025
You are not logged in. If you use a Fediverse account that is able to follow users, you can follow this user.


I was on Windows 7 until April of 2021, when I was taking a certification exam remotely, and didn’t find out that the software they used for it didn’t work on 7 until after I had paid the registration fee. Windows 10 was useable enough, but I never thought it was preferable over 7. Anyway, I’m on Bazzite now.