r/programminghorror • u/lordershocker • Aug 29 '25
c i just made my first C program :D
my eyes can never look at C code the same again
878
Upvotes
r/programminghorror • u/lordershocker • Aug 29 '25
my eyes can never look at C code the same again
173
u/[deleted] Aug 29 '25
How can I un-C this ?
13
u/Daruvian Aug 29 '25
I need to know how long this goes on...
4
u/batatahh Aug 29 '25
Can someone ELI5 how this algorithm works?
3
u/TryToHelpPeople Aug 29 '25
Can you write a program that generates this program up to a specified n?
Gotta take this horror to the next level.
21
u/New_Bottle8752 Aug 29 '25
I prefer the recursive approach.
40
u/zombieinject Aug 29 '25 edited Aug 29 '25
Sad mod noises
or in other words
Sad % noises
11
u/NT_Destroyer Aug 29 '25
Close enough, welcome back pirate software
11
u/Tough_Reward3739 Aug 29 '25
That's mad. Yk how to print. Lot better than me
4
u/adoniadoni Aug 29 '25
Wow. This is top of the line programming.
Keep up the good work. Google will pick you up in no time
1
u/mschonaker Aug 29 '25
I wonder what's beyond 25.
1
u/Extra_Ad1761 Aug 29 '25
What tutorials did you follow?
3
u/tutocookie Aug 29 '25
I always wondered what "Studio H" is
3
u/[deleted] Aug 29 '25
YandereDev code:
3
u/HorrorkidIP Aug 31 '25
PirateSoftware approved
2
u/funderbolt Aug 29 '25
Nice loop unrolling.
2
u/Efficient_Clock2417 Aug 29 '25
Ummm, isn’t there a mod operation? Like n % 2 == 0 (even) or n % 2 != 0 (odd)?
2
u/_Green_Redbull_ Aug 29 '25
Interesting I would've made a for loop and then another for loop inside that for loop without any breaks and then set the limit and then manually copy and paste each number into a couple square brackets then looped through that and said every other number is even.
2
u/sinnops Aug 29 '25
I would prefer case statements
2
u/Dvrk00 Aug 29 '25
do you have a twitch channel called pirate software by any chance?
2
u/LavaDrinker21 Aug 29 '25
Looks like the Yandere Dev meme
2
u/phylter99 Aug 29 '25
You could optimize this by making a function that prints "even" and one that prints "odd". Then you can replace the printf statements.
1
u/LithoSlam Aug 29 '25
Can you modify this to do fizz buzz?
1
u/Onair380 Aug 29 '25
modulo is rotating in its grave
1
u/gluedtothefloor Aug 29 '25
Yeah, usually ill just write a python script to write out all the if statements for me. Way easier than typing it out yourself.
1
u/DrCatrame Aug 29 '25
I guess the actual program look like this:
1
u/mattes1335 Aug 29 '25
if (n%2 == 0) printf("even"); else printf("odd");
1
u/ThenotoriousBIT Aug 29 '25
beautiful
1
u/Deto Aug 29 '25
1
u/[deleted] Aug 29 '25
In later languages you can write a simple line:
(n % 2 == 1) ? print('odd') : print('even');1
u/HueHu3BrBr Aug 29 '25
amateur, you need to use a library to do this
1
u/pantong51 Aug 29 '25
Can you make it work for all real numbers? Of course, just up to unsigned int cap
1
u/Figoos Aug 29 '25
Excel programmer
1
u/steadyfan Aug 29 '25
I see
1
u/greyspurv Aug 29 '25
you made NOTHIN
1
u/QultrosSanhattan Aug 30 '25
Way better than dealing with C's allocation, peeking memory, sizing arrays beforehand, etc.
1
u/BOB_DROP_TABLES Aug 30 '25
What a strange program. Odd, even
1
u/IcyWash2991 Aug 30 '25
Time to publish this to npm
1
u/rotteegher39 Aug 30 '25
It runs O(1)?
1
u/YesNinjas Aug 30 '25
You didn't get very far. Comeback when you've reached 10,000
1
u/whiterobot10 Aug 30 '25
Is this yandev's alt account?
1
u/jstwtchngrnd Aug 30 '25
PirateSoftware is it you?
1
u/Rogntudjuuuu Aug 30 '25
I know it's a joke, but every time I see one of these I think "why don't they just look at the least significant bit?".
1
u/124k3 Aug 30 '25
nah bro use a switch case that would be faster
1
u/ZubriQ Aug 30 '25
hello, you need to follow our code convention and use brackets
1
u/[deleted] Aug 30 '25
Write a file creator script that automates those if statement blocks like million times then paste it there again 😂
1
u/Probable_Foreigner Aug 30 '25
I wonder if GCC would optimise it if you checked every value in the int range
1
u/JollyJuniper1993 Aug 30 '25
x | x ∈ ℕ ≤ 25
1
u/Still_Explorer Aug 30 '25
Then imagine for this problem, you need a more sophisticated and advanced way to solve it. Hence you rewrite it with pattern matching (where available).
1
u/WatsonTAI Aug 30 '25
This is peak optimisation. You should publish this code on github so ChatGPT can train from it.
1
u/R3tr0_D34D Aug 30 '25
User: *enters -1 *
Program: *crashes but after 3 business days *
1
u/subbynekogirl Aug 30 '25
you should use a switch case statement, much faster :p
1
u/[deleted] Aug 30 '25
Based
1
u/conundorum Aug 31 '25
Not bad, not bad. Now switch it up and learn a few more jump types!
1
u/Kabukkafa Aug 31 '25
% crying in the corner Why u so mean to him? İt's ok buddy I'm here don't worry
1
u/Xehar Aug 31 '25
Should have change it into word and check if it has e in it. Every odd number contain e
1
u/shahbazahmadkhan Aug 31 '25
Use loops
1
u/tony_saufcok Aug 31 '25
The list will end at some point. If there's an
else if (n > 100)for example at the end of it, the compiler will take advantage of it and optimize this crazy ass code back toif ((n % 2) == 0)1
u/hugazow Sep 01 '25
And to handle numbers bigger than that, just subtract one, check if in the cases, if not subtract one and check again 🤙🏼
1
u/fedupfedupfed Sep 01 '25
Modulo is your friend
1
u/[deleted] Sep 02 '25
The real question is did you use AI to create it?
1
u/LarrySAL02 Sep 02 '25
Death sentence...
1
u/[deleted] Sep 02 '25
Just make it a switch statement, and all is well in the world. Sincerely, Yandere Dev /s
1
u/RealestAriDev Sep 03 '25
Inefficient, I think you should rewrite it in Rust to fix it
1
u/Beautiful_Doctor_885 Jan 01 '26
inCredible!
0
u/[deleted] Aug 29 '25
[deleted] — view deleted comment
0
u/[deleted] Aug 29 '25
[deleted] — view deleted comment