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
- 6 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.
Daedskin@lemmy.zipto
askgaming@piefed.social•When was the last time you experienced being "skilled" at a game?
1·20 days agoNow that Awesomenauts is back up and running, I’ve been doing pretty well at it this past week
Daedskin@lemmy.zipto
Asklemmy@lemmy.ml•What is your absolute favourite track from a video game?
7·4 months agoHard to pick just 1, so here’s a list of ones I deem notable from a few different games:
- 14.3 Billion Years — Outer Wilds
- Undertale — Undertale
- City of Tears — Hollow Knight
- Under the Eye of Kibenya — Heaven’s Vault
- No publicly available version of this one; but the game and soundtrack are good, so they’re worth a buy
- Private Room — Five Nights at Freddy’s: Sister Location
- Tiny’s Theme — Mario Golf
- Cleopactra — Ms. Pac-Man Maze Madness
- Dive Into the Mellow — Sonic Adventure 2
- Fathomless Tomb — Deep Rock Galactic
- They Might As Well Be Dead — Risk of Rain 2
- xX_TF_CNS_FloatingBits_Mp3_Xx (Floating Bits) — The Finals
Daedskin@lemmy.zipto
Technology@lemmy.world•AI in Wyoming may soon use more electricity than state’s human residentsEnglish
5·4 months agoYou can come back, you’d just have to take the slow way
Daedskin@lemmy.zipto
Ask Lemmy@lemmy.world•Why do people switch from chrome to Brave browser and not to Firefox?
2·4 months agoWhen I’ve used Teams for meetings from my home computers, I use the web version (as I don’t really want to instal the app.) I’ve never had an issue with it on Firefox; not even on devices running Linux.

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.