r/learnprogramming

Why is the output of this C code so unpredictable?

#include <stdio.h>

int a = 1;

int fun(){
    a = a * 2;
    return a;
}
int main() {
    int x = a + fun() + fun();
    printf("%d", x);
    return 0;
}

I tested this C code on Programiz and it consistently printed 8.

Thing is I got no idea how it's 8 because whether the expression is evaluated from the left or from the right, it just doesn't add up.

Does this depend on the compiler?

I would appreciate clarification on this.

reddit.com
u/everydayreligion1090 — 3 hours ago

non-tech background, started learning python today just to build a skill, is it even worth to do so?

i am from a non tech background and i want to get hire in big4s , commerce graduated, pursuing pgdib and today i thought of learning python just to build a new skill to add into my resume, always heard that its really tough for the non tech background people, still confused that will it be any beneficial in my career because i have seen several posts which requires python even if it is a non tech one, so should i pursue it or not or is it actually tough to learn?

reddit.com
u/Slight_Past_5578 — 3 hours ago

I’ve been working with full-stack development for almost 4 years. Is it worth investing time in CS50?

I’m a developer with almost 4 years of experience building full-stack apps, but I still feel like I’m missing some core fundamentals in computer science and software engineering.

I’ve been considering taking Harvard’s Harvard University CS50. Has anyone here taken it at a similar stage in their career, or even later on?

Did you feel it was worth the time investment, or are there better ways to strengthen foundational knowledge once you already have professional experience?

reddit.com
u/Motor-Wonder-5960 — 4 hours ago

I need help learning Python

I am trying to learn Python for 3 YEARS but I am just unable to do it I am stuck in the vibe coding loop I try to learn then flush everything with AI I am looking for advice on how to stop it and actually learn coding!

reddit.com
u/-ItzKira — 9 hours ago

Where do people write code?

helloo!! im new to coding and ive been wondering where people actually writr the "code" theyve learned?? like do you download them from somewhere or is it built in the computer or laptop you use? tyia !! any tips or advice would be really helpful :]]]

reddit.com
u/cluelesskid22029 — 10 hours ago

Advice with learning web development.

i have been learning python for a while at home and i also go to college where i have continued to learn. in a few months i have to do work placement i found a company but one of the main tasks they have assigned me is to fix/re-create their website. i have very little understanding of web development or how to go about learning it. Now my question is, am i over my head with this task given my main knowledge is with python, and how should i go about preparing/learning

reddit.com
u/InvestmentDangerous — 6 hours ago

How do you transition from just writing code to actually thinking like a software engineer?

I’ve been learning software engineering for a while now and recently started noticing how different building real projects feels compared to following tutorials.

So far I’ve used Java the most, but I’ve also worked with Python, JavaScript, Node.js, React, and Next.js on small projects. One thing I’m struggling with now is understanding how experienced developers approach building larger and cleaner systems without getting overwhelmed.

For those further ahead in software engineering, what mindset or skill helped you transition from “writing code that works” to actually thinking like a software engineer?

reddit.com
u/kinyua_14 — 8 hours ago

Advice

Hi All,

Hoping for some advice.

My son loves his Roblox/gaming and is interested in learning how to create games.

I am happy for him to do this if it means he is learning a skill.

Are there any apps out there that you could recommend for a 9 year old?

Cheers

reddit.com
u/Glittering_Advance56 — 10 hours ago

Is coding just an infinite string of 'how was I supposed to know that?'?

Hello everybody,
I'm learning C# and having a blast with it. I’m having a bit of an epiphany though.

I feel like I understand most of the concepts I’m learning pretty quickly, but I keep running into moments where I think: I probably could’ve figured this out if I had known the term.

For example, I was trying to make a square flip and couldn’t get it working, so I went to good old GPT. It spits out some code and I’m like, “Yeah, that makes sense… but what even is Mathf?” Then it says something like “a collection of common math functions,” which doesn’t make things more clear. Another example was seeing ? used as shorthand for an if statement, I'd been trying to make the square flip earlier with written out if statements.

So I’m wondering: is this just a normal part of learning programming that stays with you throughout the whole journey? Or do you eventually reach a point where these moments become less frequent?

TLDR: I understand coding conceptually way better than I know the names for things.

To be clear, either answer inspires me. I’m mostly curious what the experience is like for people further along.

Also also, tips for this are highly welcome.

reddit.com
u/Letbutt — 22 hours ago

Python for Beginners- Quick Learning Videos

Hello all, I am looking to learn python AGAIN and looking for some videos where they can quickly go through the basics in few hours. Any recommendations?

reddit.com
u/NinjaKG01 — 16 hours ago

why is java so difficult for me ???

So am in 12th grade rn and I had computer applications since grade 9 ...we were taught java and now it's 12th I still can't figure out how to do programs like array ,string etc...(idk if this is the right sub to post this on tho)

reddit.com
u/RealisticSpend3280 — 22 hours ago

Is the average person just stupid?

I would describe myself as averagely intelligent. I’m not incredibly dumb, but I’m definitely not some kind of genius either. I went to a Gymnasium (German academic high school), usually had grades around a B/C average, and then went on to study at university. (Master’s in Mathematics with a grade of 1.3). I’m not mentioning the grade to brag, but to give an honest picture of myself.

I personally feel incredibly stupid. And not in that ‘oH i’M sO bAd, i’Ll pRoBaBlY gEt An F’ kind of way, but genuinely slow in the head at times, which honestly could also be due to my drug use over the last few years. Despite that, I’m aware that objectively, in terms of education and salary, I’ve achieved more than 95% of people in Germany (I completely pulled that number out of my ass).

Am I drastically underestimating myself here, or are most people out on the street actually even dumber than me? When I talk to colleagues at work, I feel like the most mentally handicapped Neanderthal alive. At the same time, I know I can’t be that stupid, otherwise I’d be in a completely different place professionally right now. Does anyone else feel this way?

reddit.com
u/throwaway87146146559 — 18 hours ago

What is the actual difference between a for loop and a while loop?

please don't judge me, I'm a complete beginner. I've been googling this for a while and I think I kind of get it but I'm not sure.

from what I understand a for loop is when you already know how many times you want to repeat something, and a while loop is when you keep going until a condition is false. But then I tried writing both and got the same result which confused me a lot:

```python

for i in range(5):

print(i)

i = 0

while i < 5:

print(i)

i += 1

```

reddit.com
u/Sofiatheneophyte — 1 day ago

I built a "Chess Puzzles for Developers" app to help build active coding habits

Hey r/learnprogramming,

I'm a professional software engineer primarily working in Python, but lately, I've been doing a focused study of DSA in C++ to improve my active coding abilities and get a better grasp on memory interactions. During this process, I realized that while grinding long algorithms is incredibly useful, I was missing a way to drill quick, rapid-fire syntax and logic exercises—something akin to doing tactics in chess.

So, I built CodeQuizz (codequizz.com).

The core idea is simple: it generates short, focused coding puzzles to train your execution instincts.

Here is how it works:

  • Infinite AI Puzzles: Instead of static questions, an AI engine crafts clean, production-grade code snippets with bugs, missing return types, or logic gaps for you to identify. Because they are generated dynamically, every run is unique.
  • Tactics Elo: It tracks your performance with a dynamic rating system (just like chess), so you can actually watch your engineering logic improve over time.
  • 36 Languages Supported: Whether you are working in Python, diving deep into C/C++, or exploring something else, the environments are ready.

It's currently in Public Beta, which means it is completely free with unlimited access.

I’d love to get some feedback from this community. Check it out and let me know what you think. I'm actively looking to improve the engine!

Link: https://codequizz.com

reddit.com
u/Low_Breakfast773 — 21 hours ago

My Story of Learning to Programming

From 2019-2022 I was majoring in Nuclear Engineering. In 2023 I decided to switch majors to CS. I did my CS major in 2 years, and graduated in Dec of 2025 (from a small uni in Illinois [USA]).

After graduated w/ CS degree I did not feel 'ready' to be a professional programmer. So instead of searching for a programming job, I decided to fully focus on self studying, and this is what I've been doing for past 2 years since I graduated.

Now I don't want to make it seem like college was a waste for me. No, it was a good step forward in my education (and also thankfully I did not pay much since I got a full ride scholarship).

Actually, some projects I built while in college that I'm proud of (although they are not production level, only educational) are: a virtual cpu (c++), and a 2D zombie-shooter like game (Pygame, Python). Both of these projects are college course projects, however they where really 'solo projects' as the course was mostly like "build something with what you learned from the course". I bring these up to show you that I wasn't slacking in college, at least not completely, and that I did learn some things about programming in college.

However, I would most definitely say I was just not ready to be a programmer after graduating. The main reason being that 2 years of CS was just not enough, at least for me. But thankfully, as I said earlier, I have put in another 2 years of self studying programming since graduating.

So, what have I studied? I have studied front-end programming, back-end programming, game programming, and graphics programming.

Some front-end only websites I have built are: battleship (JS), and pixel art (JS). Also, I did built a 'CV builder' front-end only website using React, but I no longer have access to the repo. All this is to say that I did put in some good time into learning front end programming, and did gain some ok skills in it.

For back-end, I studied MongoDB, SQL, and a little of Express.js. I did build one full-stack app that was like a very terrible twitter (Express, Node, Heroku, MongoDB, React). I also have read the book "TCP/IP Illustrated". I would say this is my weakest programming skill, or at least least experienced in.

For games programming, let me just list the projects I've made: snake (SFML, C++), snake 3D (OpenGL, C++, my art too!), Flappy Bird 3D (OpenGL, C++), Super Mario Bros Clone (SFML, C++, ECS), Geometry Wars (SFML, C++). All are educational builds, nothing production level, but still good work I'm happy with.

For graphics programming, I've built: 2D ray caster (C++, SFML), ray caster/tracer (C++), two software renders [1] (C++) [2] (C++, SDL2), and a noise demo (C++, OpenGL).

I also have studied other things some not so deeply others more, which include: math (linear algebra, geometry, calculus, differtial equations), physics (classical mechanics, E&M), OS theory (very little on this one), and some other subjects. However, I'm not so good at any of these, but my foundations and inuition for what I have learned is very solid.

That's who I am as a programmer. Ok, so what will I do now? Try finding a job? No. I still find programming to be incredible difficult, and feel like I still have much to learn. And, I don't think I'll find a game or graphics or web job. So, I will continue to study...

Oh also, I'm not like John Carmack (Doom guy) or Tim Sweeny (Epic CEO) who can do like +8h programming days. No, at most I do 6h, and not so consistent with it. Also, for me programming and studying can be very painful mentally, has been and still is, probably will always be.

That mental pain is, I think, the main reason why I've decided to slow down on studying. I am also running out of my saving and parents want me to get job, so I'll be getting a part time job (non-programming). This seems like a good path for me, a path that actually makes me happy. But, I won't give up on programming. I will try to programming 1h everyday.

reddit.com
u/Crafty_Ganache_745 — 18 hours ago
▲ 6 r/learnprogramming+1 crossposts

I built a DSA learning tool after failing many coding interviews

- I kept failing DSA interviews for the same reasons:
- I couldn’t solve problems efficiently
- I got stuck when the clock started ticking
- I memorized solutions but never understood the patterns

During interviews, my brain just went blank
Most platforms only show the final solution.
They don’t teach you how to think.

So I built DSAFun dot com.
It explains every problem step by step in plain English, teaches the intuition behind each pattern, and connects data structures to real-world examples so they actually make sense.

It also includes:
An AI tutor that guides your thinking process
Pattern-based learning instead of memorization
Cheat sheets designed to make concepts stick permanently
Interview-style practice focused on speed and clarity

Built by someone who struggled hard with DSA, not someone pretending it was easy.

Would genuinely love feedback from anyone preparing for coding interviews.

reddit.com
u/Clean-Temperature351 — 19 hours ago

Alternatives to excel for casual data analysis with an interface?

This is part of a spreadsheet I build for keeping track of my personal finances.

The table consists of a single formula which got quite big and is just below excels limit of 8192 characters per cell.
Furthermore, compared to for example python excel formulas are much more of a pain in the neck.

I'd really love to do this in python. However, user interfaces are difficult to realize in python.

Calculating once in python an then transferring to excel isn’t an option as I want it to update in real time when adding new data.

Using python inside of excel seems promising, but it’s only available when subscribing to office 365 and all the code gets processed on MS servers.

So what’s the best way to achieve this not using excel?

Like I said, the data analysis part would be a walk in the park using python. But but creating a user interface is just very time consuming. That’s like a huge benefit of Excel.

What would a more professional approach be?

reddit.com
u/Ok-Equivalent3837 — 1 day ago

Does anyone use Tumblr to store their HTML/CSS codes?

Hello!

I recently started The Odin Project and I just got to the part where you make a site using HTML and CSS. I have some experience with it and I've made a few themes on Tumblr so I'm just the most comfortable with that interface. Does anyone else use Tumblr as basically a backup github/place to work on their codes that only involve HTML and CSS? Once a code is complete I'd also back it up on github, obviously, but just while I'm working on it and as a place to showcase my themes.

reddit.com
u/Sad-Artist7044 — 1 day ago