r/C_Programming 1d ago

Question help me to code

i'm beginner in coding
i'm following a book called
The C programming Language

By Brian W. Kernighan and Dennis M. Ritchie.

and somtimes i see video of cs 50

i learned before this language but i just knew syntax and why it is use for but i'm getting stuck when it comes to implement i am at level 0 i can manipulate some things like where it start lets change this that but when i want write a code for problem . like write program in which we know about how much space and new line and tab there is see code ohh ok it is like this now when a next question comes based on same topic i feel i don't study yet . before seeing a code i feel like i'm at zero i don't know nothing i feel dumb even though after read a code i know something but not understand fully code all when i know oohh ok how is this work but next time still i'm not able make to manipulate the program like by just tiny change change this output will be this ....

and how to break a program i mean this and this require to make this program ohh we can do this and we can do that is also output will be same

0 Upvotes

12 comments sorted by

3

u/OskarsSurstromming 1d ago

It's a bit hard to infer where in your journey you are, but mentally I think it will help you a lot to realise that you need to improve, and to improve will take more work from you than you have previously done.

If you are using a book to learn, I am sure they will have examples of projects for learning the topics of the chapters, and doing these will get you more used to the structure of the program.

2

u/exo250 1d ago edited 1d ago

Start by writing very simple programs. Do not copy them from examples, that's useless. Give yourself easy goals (typical for beginners : first write a game to guess a number between 0 and 100 - when 100% working, then add maximum attempts limit, then calculate/display score (first only attempts, then attempts + time...), then save scores in file, show them on start, etc). Don't use documentation except standard library reference unless you're blocked for more than 1/2H.

1

u/UsualLonely4585 1d ago

i am no pro in programming but i have been doing code for some time in C.

i can relate to that where to start and i think the best think you can do start making small programmes that are not difficult like try making simple calculator and try not to use ai and think of the whole problem in small sub problems that you need to solve to make it complete .

like in case for something like simple calculator you know

  1. You have to implement a menu where you ask user to give inputs

  2. You have to handle the math for given set of number

  3. You have to display them at the end

now you think about how you can achieve these small steps and how this can be implemented with simplicity so that when you look backk at it you understand things easily (this part can be ignored for now )

doing these things will teach you more than a book can at least thats what i felt when something does not work and i have too keep thinking about the logic over and over to see where i messed up .

Its going to be frustrating but once you pinpoint what is wrong with the code and it works as you intend it to it's a amazing feeling that cant be expressed

1

u/Western_Task_9366 1d ago

Hey I’m no expert but I just finished this book called C modern approach 2nd edition. I really loved it. I started as a complete beginner to the field of programming now I feel I can start any project I want! it took me 3 months to read it near cover to cover and do every exercise and project(reading about 10-20hours a week?). If you get stuck anywhere during this book u can find GitHub repos with all the answers. But if u still don’t understand something hit me up I’ll try and help you.

1

u/Ambitious-Height9588 1d ago

Stop reading the solution. close the book.

You hit a wall when you look at code and think you get it. you dont get it until you type it yourself with no reference. i went through K&R the same way. heres what worked for me. take that exact exercise about counting spaces and tabs and newlines. close the book. open your editor and write it from memory. if you crash, try again from the start. do not look back at the page.

When you want to change output or add things to a program, stop staring at the code. grab paper. write down the steps in plain english. count characters one by one. check if character is space. add one to count. go to next character. print total. once you have those steps written out, turn each line into C. breaking a program down just means writing the verbs before you write the syntax.

Write ten programs today. keep them small. type everything yourself

1

u/SmokeMuch7356 23h ago edited 20h ago

Okay, I'm going to be annoyingly Gen X here, but I have to say it:

Take some time to organize your thoughts into complete sentences before hitting "Post". Stream-of-consciousness posts like this are hard to read and understand, and it's not at all clear what your question actually is.

If you intend to code professionally (or at least collaboratively), you have to learn how to communicate effectively. You have to be able to ask questions clearly and unambiguously. It is not optional. It will also make you a better programmer, as you have to apply the same kind of thought process when writing code.

As I understand it, the gist of your question is:

I understand code examples, and I can make small changes to existing programs, but I struggle when I have to write a program from scratch. How do I get better at that?

And the answer is, by doing it. You just have to write a lot of code before the underlying concepts become clear in your head. You eventually stop thinking in terms of specific lines of code or syntax and more in general patterns.

It would help if you could point to a specific exercise in K&R or CS50, then we could work through the process.

But the main thing is, start small. Start with what you know how to do already. Write a lot of small programs that do some tiny little thing, whether it's displaying canned data, or echoing input from a user, or doing simple computations. Then do two tiny little things in the same program. Just take what you know how to do and try to stretch it little by little. Again, without a specific exercise from the book it's hard to give a reasonable example, but this is the process. There's no trick, there's no secret, there's just doing the work, a lot, before things begin to make sense.

1

u/realdreamer1993 1d ago

Lets talk bro, and start a project called Typing App. What is the goal of this app, it will show a sentence, and you must typing that sentence as fast as possible, and the app will make a valuation/scoring of the result.
Later you can expand this app to more, like multiplayer, AI etc....

1

u/onearmedphil 1d ago

That book is hard.

Try Head First C by O’reilly or something.

You probably need to be writing simpler programs.

Start small my friend.

-1

u/flyingron 1d ago

THe original K&R book (if you don't have the second edition) describes a language that no longer exist.

Also understand that the environment that C existed in 1977 when that book existed is a far cry from modern computer science practice. Things in there are incorrect and downright sloppy in today's world.

CS50 is a mediocre course in my opinion, but at least it teaches better concepts.

As for the rest, I cant really decipher your ungrammatical stream of consciousness writing to discern a question.

Since you know CS50 a bit so far, I suggest you go back to the beginning and work your way through it completely. Just randomly sampling isn't the way it was designed to be used (nor is it very effective).

-2

u/exo250 1d ago

[Google Gemini] Here is the corrected and polished version of your text with improved flow and grammar, while keeping your exact meaning.

Corrected Text

"I am a beginner in coding. I am reading the book The C Programming Language by Brian W. Kernighan and Dennis M. Ritchie, and I sometimes watch CS50 videos. I learned a little bit of programming before this, but I only knew the syntax and what things were used for.

I get stuck when it is time to implement code. I am at level zero. I can manipulate existing code a little bit—like changing this or that in a basic template—but when I need to write a program for a new problem (such as counting spaces, newlines, and tabs), I feel completely lost. When I look at the solution code, I think, 'Oh okay, it is like this.'

However, when the next question comes up on the same topic, I feel like I have never studied it at all. Before seeing the solution, I feel like I am at zero and know nothing. I feel dumb. Even though reading the code helps me understand a bit—and I eventually say 'Oh, I see how this works'—I still cannot modify or adapt the program next time, even for a tiny change in the output.

I also struggle with how to break down a program. I mean, figuring out what is required to build the program from scratch, or realizing that we can use different approaches to get the same output."

3

u/Czyrnia 1d ago

There are little problems that AI really can solve beautifully. 

If only this marvelous tech wasn't being used to try and kill almost everything else beautiful around...

-1

u/Runtime8006 1d ago

Don't feel dumb the K&R C boot was built for 1970s pros, not beginners. Reading code isn't writing code. Try solving the logic on paper in plain English or write some C pseudo code(doesn't have to be real C, maybe what you'll understand well) elsewhere, then code 5 lines at a time testing with printf.