In a new language, modern times and all that, I decide what I want to do, and then internet search an example of that, and these start out as simple things (I want to write a for loop, how is that done in this language) and progress (I want to write functions ) farther and farther (I want to make an OOP program) and branch out (I want to use a library to connect to the internet or a database or do math or something) until all of a sudden, it all just clicks and you are making programs without looking up stuff very often. And, even after decades in C++, I do still have to look up things I rarely use and frequently oversimply details that I do not interact with on a regular basis.
you can even do this from the complex stuff on day one, if you already know how to program but the language is new. If its your first language, you need to start with simpler problems and work it up.
I can't say I am remotely fluent in C++, despite trying to self-teach since before C++03....
To gain proficiency in programming I've taken example code of some feature I want to understand. I write multiple sample programs that start with the example code. With each new variation I change some portion of the code that pushes me to understand what the feature can do.
Before anything, you need to have patience and actual motivation. I tried to learn when I was in middle school and I'd basically fall asleep - had no patience.
Eventually, I followed the learncpp.com tutorial. After learning enough to be able to code some logic on my own, I started making a calculator. It was very simple at first. As I learned more, I shoved that knowledge into my calculator (probably the worst code I've ever written, but hey, it worked). I'd use things I learned to add more functionality to the calculator.
Eventually, I'd just keep coding things. When you get stuck, go online. If you see code you don't understand, try to understand it. Anything that takes over 5-10 minutes of googling to try and understand is probably something you should keep in the backburner to understand later when you're more advanced.
I'm only about a year in, I've accepted that there is so much that very few people could actually know all there is. Sort of how Doctors "practice" medicine their whole career, lol.
I'm still very novice but I write every day, buying an SBC was a tremendous help, being able to write code and interact with it through GPIO. Then I took on a little project and decided to write a simple chatbot and that turned out to be the biggest teaching aid. My little chatbot has grown exponentially in a year, simulating moods, listening to spoken word and replying verbally. Now I'm writing a function to allow her to interactively learn new words verbally so she learns them as her hardware hears them.
Choose a project, write something every day if you can.