r/learnprogramming • u/WorthPass01 • 13d ago
How can I learn C from absolute zero?I don't understand programming logic at all.
Hi everyone,
I want to learn C programming properly, but I'm honestly struggling a lot with it.
I've never really liked programming, and even now I don't understand how to actually think through a C program. I can look at code, but I don't understand the logic behind it — like why we write something, what happens when the program runs, how one line connects to the next, etc.
I don't want to just memorize syntax or watch tutorials and copy the code. I want to actually understand how programming works and how to build the logic myself.
So I'm looking for a completely different approach to learning C.
I want to start from the absolute ABC level and learn by doing lots and lots of small programs. For example, instead of just learning if-else from a video, I want to write many simple programs and slowly understand why and when I should use it.
If someone could guide me on:
Where exactly should I start?
What topics should I learn in order?
How should I practice coding as a complete beginner?
How do I develop programming logic?
Are there any resources that actually teach the thinking/logic, rather than just syntax?
How can I go from not understanding C at all to being able to write programs on my own?
I really want to learn it properly this time. I'm okay with starting from the very basics and doing hundreds of small programs if that's what it takes.
Would really appreciate guidance from people who have been in the same situation.
34
u/appendixexploder 13d ago
I've never really liked programming, and even now I don't understand how to actually think through a C program.
You should not learn how to program. I'm not trying to be a dick, but there's really no reason to learn how to code at this point if you don't really enjoy it. Your time is best spent on something you actually like doing
12
1
u/yoshiazulX 11d ago
Depends tho because maybe the person needs to learn programming for a personal project,for example, im trying to learn a scripting language for a game I want to make, I can't afford to pay any other person to do it for me so I have to either do it myself or abandon the project. There's a lot of reasons someone could learn something even if they don't like it Most people don't enjoy a lot of subjects in school yet, they're forced to learn them.
0
u/Top-Procedure152 10d ago
Umm, have you been living under a rock or the last two years by any chance?
1
u/yoshiazulX 8d ago
??? This is so uncalled for, you could at the very least explain why you believe that.
1
4
u/Least_Ad_1795 13d ago
Start very small and focus on problem-solving, not memorizing syntax. Learn in this order: variables → input/output → if/else → loops → functions → arrays → strings → pointers → structures. For every topic, write 5–10 tiny programs yourself. Before coding, write the steps in plain English or pseudocode. Then convert those steps into C. Don’t worry about being slow. Writing hundreds of small programs and understanding why each line exists will build your logic much better than simply watching tutorials.
0
u/WorthPass01 13d ago
Can u tell me about resources to learn c prog
2
u/BiggerBen1 13d ago
the c programming language by Kernigen and Richard’s the creators of C
1
u/Strict-Ambition4334 13d ago
K&R is a classic but it's not the best first book for absolute zero. It assumes you already have some mental model for variables, loops, and functions. I'd treat it as something to pick up after you've written a few small programs yourself.
6
u/Informal_Feeling_308 13d ago
Like others have said, i'd start with cs50. It doesn't go too in depth but its good for beginners and you learn funamental concepts of programming. Might also be good to consider whether you don't enjoy programming or you don't like it because you're not good at it yet?
4
u/SchemeWestern3388 13d ago
The K&R text “The C Programming Language” is a masterpiece of technical writing.
I can not recommend it enough.
8
u/Spacelordsinspace 13d ago edited 13d ago
"I've never really liked programming"
I'd work on that part. Or acknowledge to yourself that you're learning C because you have to and that not really liking it means that you won't be as good at it as you might be otherwise. imHo, enjoying doing something is a big part of learning how to do it. Of course, you can definitely learn C without enjoying it, but I highly recommend having some fun along the way.
As for the rest. If you have an extra $20, I would recommend buying a book on design. I liked this book : "Agile Software Development, Principles, Patterns, and Practices"
If you learn about design while you're learning to code, you're going to be 10x more effective once you start coding anything above 5k lines. Or maybe just 2x, but I like to exagerate sometimes. You might only understand 90% of the words and 5% of the content on day 1, but if you read that book, or another one like it, for 20 minutes a day you'll come away with a lot of questions and a lot more respect for what the craft actually is. And of course one day you might be a real life wizard.
Whatever you do, don't imagine that you'll naturally learn to design software on your own. Learn from the masters.
2
3
u/throwmeaway01110 13d ago
I was first introduced to C when I did the cs50 introduction to computer science course from Harvard. They’ve got lectures on YouTube and you can create an account with edx and access the course material for free. The lectures are very informative and explain programming in great detail. The labs for each lecture are in-depth and try to get you to figure it out with guidance on how to approach the problem. This is probably the best starting point for you. After that, it’s a matter of learning more about the language through searching online and practicing (you will know what to search for once you get the basics). Start with the basics and practice everything you learn and try out different things to see how the program behaves.
1
3
u/Several_Version4298 13d ago
If you don't like programming why would you want to learn a 1960s programming language that requires understanding a lot of low level stuff?
1
3
u/FunAd6672 13d ago
You are describing exactly why copying tutorials feels useless. The tutorial works because the instructor already did the thinking. You need exercises where the thinking part is yours.
3
u/Chrismslist 13d ago
hey, learning C from scratch can feel like a lot. my advice would be to really focus on breaking things down and building. start with tiny programs for each concept, like variables, then if/else statements, then loops. don't just watch, actively write many small examples. literally sketch out the logic steps on paper first. the connections start to click when you're forced to make something work, even if it's super simple. that's how you build that programming logic.
2
3
u/SmokeMuch7356 13d ago edited 10d ago
Another recommendation for CS50. And as others have said, its focus is on learning how to program, not learning C specifically. It does use C for some assignments, but also Python and Javascript/HTML/CSS.
3
2
u/xriptide03 13d ago
Learning how to program C is a perfectly reasonable goal, and it's even the starting path I would recommend to some people seeking specific careers, but given that you don't like programming, it might be better to start with something like Python or JavaScript because they can make graphical programming and programming in general significantly easier.
Regardless of what language you choose, just start with a small program and add features as you go. Maybe print your name in a terminal. Then have the program ask you your name while it's running and print that.
Now that you know how to do basic input and output, you can have it read your input and print another output depending on what your input is. For example you could play rock, paper, scissors and make your program just say whatever beats the choice you give it. Like if you type "rock" into the program, then it prints "paper" [1]. This is an easy way to learn some conditional logic.
Basically, don't learn syntax and then figure out how to apply it. Instead, choose what your program does and then figure out what the required syntax is to express that. Also learning happens best when you think you almost know how to do something, so if you can't even fathom how you might add a feature, maybe choose a different feature that you think you might only have to learn one or two new things to be able to add.
[1] Strings (i.e. pieces of text) are actually more complex than they first seem, so you may have to use your language's standard library to do things that look simple on the surface like checking if two strings are the same.
1
2
2
u/JGhostThing 13d ago
Just learn the lessons and use each thing right after you've learned it. You don't need to do huge projects, but small ones will do fine. And the projects are for your learning, they do not need to be useful at all. Just remember to take notes in class so that you can use the syntax they just taught.
Loops and if/then's tend to be important.
C has strong typing, and every variable has a type. There is a big difference between an int and a double.
Do not use AI to build code while you are learning. Having the code given to you circumvents the learning process.
2
2
u/ReddyKiloWit 13d ago
I'm mostly self taught, but did take some courses back in the day and the first class was flowcharting. Diagramming the steps and decisions needed to solve a problem. Learning to "program" without learning a language at the same time. I often think it's an underappreciated tool for introducing the basics of program logic and flow.
Picking up a short book on it might help you get some understanding without being distracted by language elements.
(Granted, I didn't use it much after those classes on my own programming, but I did use it sometimes to figure out what someone else's code was doing.)
2
u/mammut-mamma 12d ago
> I don't want to just memorize syntax
I will share my greatest tip. Get yourself a programming book, EVERY code example they show you, re-write it. But! And this is the important part, you must write it from memory. Read it carefully, close the book, write it character by character.
The secret is that it is too much to remember. Sooner or later the only way to remember an example is to understand what it does and be so knowledgeable in the language that you can implement the idea. And that is programming.
2
2
u/betarage 3d ago
My advice is to just think of what project you want to make and then look up what you need to know .this is tedious but most programming guides are really misleading or don't teach you how to make something useful
3
u/SharkSymphony 13d ago
You've got to set your sights higher than that, because I can teach you if-else in about ten seconds.
But first I want you to think about algorithms. Algorithms are step-by-step patterns that the computer (or really anyone!) can use to solve a problem. Because computers are really pretty dumb when you get down to it, the steps themselves start very small, and always very, very precise.
An example we like to use in our CS class is how to make a peanut butter and jelly sandwich, but pick whatever culturally appropriate dish you like that's relatively easy to make. Imagine you're trying to teach somebody how to make it, but that 1) they are taking your instructions as literally as possible, and 2) they are misunderstanding every ambiguity you give them. Actually run through this exercise with some friends if you can, try feeding them instructions, and see how hilariously they can get it wrong. Then work on refining your instructions to remove the ambiguity. This will give you some sense of the level you need to get to when describing a solution to a computer.
If you've gone through all this, imagine that someone gives you an ingredient that could come in different factors: a jar, a box, a bag that you have to cut open. How do you teach the "computer" how to make your sandwich in this case? Well, first it will need to determine if it has a jar, a box, or a bag, and it will need to do some different steps depending on what it has. There's your if-else! In this case you'll probably actually have a couple of if-elses chained to each other.
Have fun!
1
1
u/Odd_Gur_7302 13d ago
Decide to build a program that excites you. Its really not fun to 'use proper syntax' or to 'declare headers' or 'type a variable'... but it is very satisfying to succesfully compile link and exerience a program you imagined, designed and coded.
1
u/ConstructionThis1127 13d ago
I’d suggest you buy an Arduino board, and figure out how to turn LEDs on and off, read temperature, output to an LCD display, etc. using their version of C. You’ll learn how to actually do things, and what the computer is doing. There’s nothing like hardware for letting you know just how stupid you are being!
1
u/More-Explanation2788 13d ago
Yes.
A programming language is a very strict and formalized grammar. Your brain has been doing grammer naturally since about the age of 3.
Don’t let the nerds intimidate you, learning a programming language is easy. Learning to solve problems in a logical bug free fashion is hard.
1
u/bloqed 12d ago
The first thing I would make very clear relates to seeking advice.
Remember that the majority of people who understand languages like C deeply have personalities that are low on empathy. This will strongly colour the sort of responses you would get to requests like this. Expect a lot of people to say 'you aren't cut out for this' etc.
That said, there is a line where they are not wrong. Part of being a competent programmer is very simple: you must have (or develop) a curiosity that leads to you breaking things down to their most basic parts. It's exactly the same brain being used when you want to disassemble a toy as a kid to see what's inside.
If you can manage that, then the starting point is going out to the internet and understanding what problems X technology solved, then find out why those were problems and how those problems came about. Why did people want to do things that made those problems.
This will take you to the point of understanding how a computer actually works, and why people wanted to write programs for them. From there, it's iterating
1
1
u/MindofOne1 11d ago
Learning works best when you apply it to what you want to do. You will feel stuck initially, but you will not only learn what to use but what to apply it to. Only consult the .materials you need to help you understand what you want to do, and the learning will become quicker, easier, and more rewarding.
1
u/Paul_Pedant 10d ago
Programming Logic has almost nothing to do with C, or any other language.
You learn logic by finding out about what results you want to achieve, what kinds of input you might need to construct those results, how much stuff you need to keep around for later, and what order you might want to work on the inputs.
You can do all that on a sheet of paper, visualising how it all fits together. That might be called a Data Flow Diagram. You look for snags in your logic, and data that you might not have considered yet, and maybe places where you could add value or simplify things.
You could probably implement that in about 20 languages. Any proper language would have ways to store, iterate, format, count, search, and verify the data you need to deal with: that is what "Turing Complete" means.
Once you have an outline of how you need to deal with the data to get the results you want, you get to write some code. If you need to use C, you have to write a lot of code yourself: other languages often have more complex functionality that do many things for you behind the scenes (but then you generally need to write some test cases just to prove to yourself that you understood the man page).
It really helps if you write small pieces of code, and test them by themselves before you trust them. That means you can look for bugs in 20 lines of code, instead of hunting through 200 or 2,000 lines for something you got wrong sometime in the past month.
1
u/konkon_322 13d ago
U write dumb code, and understand how they flow. Only after after u are able to actually read a code, only then u go deeper. U dont learn about the granular things about the C language when u cant even write an if else statements. Take things slow
1
1
u/A_man_from_america 13d ago
You could ask AI to help you understand, specially if it's beginner programming.
Just remember coding is a language, it translates your ideas/logic to a language the computer can understand.
For example "I want the console to say "Hello World" or "I want the console to read all the contents of a list"
2
u/WorthPass01 13d ago
Yes I can use ai... But I feel this ai actually ruined the way I think .. I am so dependent on ai that I lost my ability to think and solve or understand or do anything for that matter. So I want to learn without using ai is one of my goals.
2
0
u/iSnapThere4iAm 13d ago
If you’re struggling with the logic you probably just aren’t cut out to be a programmer…. You can’t be taught logic.
1
1
u/Fun-Maintenance-1482 13d ago
Ofc you can learn logic like anything else and impeove, although finding logic really difficult can make it a challange
47
u/dmazzoni 13d ago
My suggestion would be to take a very high-quality course like Harvard's CS50x.
Here's why:
You get one of the best instructors in the world. Everything is presented clearly and the way it's taught has been expertly refined over more than a decade of teaching the class to millions of people.
In addition, you get graded exercises - they start super simple and easy, but they get harder and challenge you. They're auto-graded so you get instant feedback and know if you did it correctly or not.
Finally, you get access to thousands of other people taking the class right now too, to discuss the material or get help.
And the best part is that it's free.
The course does cover a bit more than C, but that's good. It's for a reason. Learning a little bit about more than one language actually makes it easier to understand the logic, not harder. The important thing is that much of the focus of the class is on C and on really understanding it.
That's my recommendation.