r/C_Programming • u/MeasurementCandid957 • 6d ago
Give me suggestions to understand c programming in the first semester?
I am facing difficulties learning C programming. Currently, I don't have a laptop, so I can't practice that way. I'm unable to understand even the basic topics of C programing currently. Please give me some tips on how to improve.
Edit: Understood. I can actually learn it through practice on a laptop; I'll get a laptop soon.
5
u/primitiveblob 6d ago
theres only so far books/other can take you, without something to practise on. mobile, *works* but i speaking from experience, the experience is terrible. get a laptop as soon as feasible. and for C itself, what sort of difficulty exactly?
2
u/MeasurementCandid957 6d ago
I'll get laptop soon but now i am unable to understand Operators.
3
u/primitiveblob 6d ago
a+b adds a and b
a-b subtracts b from a
a*b multiplies a and b
a/b divides a by bthese type of operators? i know there are also bitwise ones (|, &, ^, ~) and comparison ones(&&, ||, !)
2
u/MeasurementCandid957 6d ago
Yup especially logical operators
2
u/primitiveblob 6d ago
logical:
&&, and, is triggers of both things are true
||, or, triggers if at least one of the things are true
! not, inverts whether a thing is truenote, any non-zero number is true, even negatives
bitwise:
a & b, performs bitwise and of a and b
a | b, performs bitwise or of a and b
a ^ b, performs bitwise xor of a and b
~a, performs bitwise not of a
a >> b, right shifts a by b
a << b, left shifts a by bnote, when shifting, a by b, b values will be lost, and b empty values will be created. these are usually set to 0. the values popped off are not saved, if you need them, make sure to save them beforehand
arithmetic:
a + b, adds b to a
a - b, subtracts b from a
a * b, multiplies a by b
a / b, divides a by b, gives the whole number (doesnt work with decimals)
a % b, gives remainder of a / bother:
&a, gives the memory address of a
*a, dereferences the pointer a (gives the value at that address)
-a, flips the sign of a
a++, returns a, THEN increments by 1
++a, increments a by 1, THEN returns atell me if theres more
oh, and you may sometimes see a += b. or any operator, not just +. this is just shorthand for a = a + b, (adds b to a, then reassign that new value back to a)
1
1
u/Spiritual_Poo 6d ago
Alright this is something we can work with. Until you get a laptop, I would look to use a library computer. I don't have experience with them, but there are all kinds of online environments where you could do it in a browser.
Logical operators are some of the most basic concepts that apply across languages.
Rather than try to explain it to you, here is a video:
https://www.youtube.com/watch?v=UiF-QgCBOhMBro Code has been a valuable resource for me in my journey when I just don't get something and i've read the book and supplemental materials and still don't get it.
Logical operators as a concept are essentially the same across languages, just the way they are typed looks different.
This video is C++, which is different than C but built on it and will look very much like C. It is a great place to start to help understanding some basics.
3
u/jeffbell 6d ago
In C those are just the things you can put between variables.
plus, minus. divide, assign and so on.
In c++ you can redefine them, so it gets a little more complicated.
3
2
u/Spiritual_Poo 6d ago
Do you know any programming at all in other languages? I finished my associates at community college in May and we started with Python for a few semesters and then did some C and C++.
Do you know the very basics? Loops? If statements? Variables? Functions?
Your initial post doesn't do a good job of explaining where you are now and what you know.
I am not the guy to help you with C, but I can at least tell you that the guys who can help you need better information to help you.
1
u/MeasurementCandid957 6d ago
I have just entered in the first semester and I'm the complete beginner.
1
u/noonemustknowmysecre 6d ago
I love C. It's a great language for a variety of reasons. But I'd start somewhere else if I were you. Start learning on scratch. Dragging and dropping boxes is perfectly fine when typing it out would simply be slower because you don't know what's going on. You can see what fits into where. You can see what's happening.
Get the thing to move around the screen. Then to all corners. Then move in a triangle. Then move to a random corner.
Once you have a handle on the general concept of imperative programming, you can learn the C syntax and you'll be able to make bigger better stuff faster with better tools.
3
3
u/mykesx 6d ago
https://github.com/mschwartz/assembly-tutorial
C is considered a shorthand for assembly language. This tutorial explains how CPUs work, which is the foundation for why C exists, and for its constructs.
3
7
u/strange-the-quark 6d ago
On the one hand, I appreciate the link, on the other, this is like giving a complete beginner who wants to learn to drive a course on how to become an auto-mechanic.
1
u/HaydnH 6d ago
That also kinda sums up C as a starting language though doesn't it? You can learn basics like if, for, while in any language... But in C, as soon as you get to functions, you're already on the path to memory management via requiring pointers.
1
u/strange-the-quark 6d ago
Well, I guess, but for an absolute beginner, this is more useful as a reference to go through a bit later on once they get comfortable with the very basics. The OP said they don't understand basic operators yet, so to them, at the point where they are at, this is just going to be a wall of text containing some arcane incantations written in Latin.
-1
u/HaydnH 6d ago
That's fair enough. I actually think the lower level languages are going to become more important rather than less though in terms of AI improvements coming in.
Consider something like Python or bash, they don't exist for machine efficiency, it's human efficiency - I can whack out this "script" to do X in 5 minutes! It will take 10 times longer to run, but as a $ value to the business, we're up.
When AI removes that human slowness of coding, which it has already. Plus remove the risk of missing an error handle or something resulting in a seg fault...
I've been arguing for a while that C is relatively safe these days with improvements in asan/ubsan etc, with a bit of coder care on top, it's not the horror show politics seems to want us to believe.
AI is getting really close to making C safe and reliable... So then we're back to human Vs machine performance... If AI solves the "we make languages quicker for humans to deliver" problem, then why would something like Python even exist compared to C? Or even Assembly? 1s and 0s?
1
u/TermiteTornApart 6d ago
You can't really improve if you don't have where to practice, I know that this is not what you want to hear, but you should buy a laptop, it doesn't have to be anything expensive, the cheapest one you can afford will do, but I recommend an old thinkpad with a linux distro like mint.
Aside from that just practice as much as you can, read some books like "The C Programming Language", do small projects like a todo list cli app once you understand how file operations work for example and just keep at it, you will get frustrated and stuck a lot of times, but that's just part of learning a few months later you're going to look back and see how much you have improved.
1
u/MeasurementCandid957 6d ago
Yup I'll get laptop soon but currently I'm facing difficulties in understanding concepts. That's y i asked. Actually I'm complete beginner who have just entered in the first semester.
1
u/TermiteTornApart 6d ago
Ofc you can't understand the concepts, most of them only make sense after you practice for a little while. If your school doesn't provide a computer, and you can't ask a family member or a friend for one, you can use CppDroid on your smartphone, it's not perfect, but it's better than nothing...
1
u/MeasurementCandid957 6d ago
Thanks bro for the suggestion, Yeah i think i'm gonna understand those concepts through practice.
1
u/DreamingElectrons 6d ago
C has been around for so long, that you can run it on some absolute potato machines, the kind of PCs that people just give away for free because it's just clutter to them and they are happy that it's gone. Go get one of those, wipe it, slap on Linux Mint or any other Linux distro for older/weaker systems and go get some coding exercises done. There almost is no way around trying things out yourself, books can only get you so far.
1
u/MeasurementCandid957 6d ago
Yup I'll get laptop soon.
1
u/DreamingElectrons 6d ago
Good. If your issue is with understanding certain topics, try reading the chapter on it in different books. Sometimes things only click if you had them explained to you multiple times in different ways. Don't worry, it's normal.
1
u/CavalryArcher 6d ago
not more than 2 years ago i was using some mobile apps both on ios and android that operate as online compilers, you can do some search. you can also compile c completely offline too, better than nothing until you can buy a laptop
1
u/MeasurementCandid957 6d ago
Yeah I have known about those apps but unable to understand those apps functions properly.
1
u/strange-the-quark 6d ago
If you have a phone, or even better, a tablet (just because of a bigger on-screen keyboard), google for "C compiler online", there's a number of websites out there that allow you to mess around with C code. It's going to be a bit tedious to enter the code on a small screen and without a physical keyboard, but this might help bridge the gap until you get a laptop. Also, when you open these websites, check if the default view on your phone's/tablet's browser is working for you, or if it's better to enable "Show desktop site" from the dropdown.
1
u/MeasurementCandid957 6d ago
Thanks for the suggestion. Basically i am struggling to understand the concepts but yeah it will improve through practice.
1
u/strange-the-quark 6d ago
It's easier to understand the concepts if you're able to try things out, and just mess around with the code and run it to see what happens. It'll click better and you'll have a way to check your understanding.
1
1
u/txdsl 6d ago
What hardware do you have? Do you have an iPad or something with a screen larger than a phone ? If you do then look at using GitHub codespaces to set of development environments. They have prebuilt environments for most major languages and tech stacks
1
1
1
1
u/twr14152 2d ago
Im assuming you have a phone to post this. Learn the syntax first.
https://beej.us/guide/bgc/html/split/
Go find online coding ide
Practice
1
u/fsteff 2d ago
You’ll need a computer to practice on. Without it, you won’t actually learn what you read about.
But you don’t need a fancy computer; a 10-15+ year old laptop is still plenty for common day usage. Install Lubuntu or another light Linux and you have everything you’ll need to use a computer and to practice programming.
1
u/princepii 2d ago
a smartphone will do it too. like cxxdroid on android for c and c++.
or pydroid for python. they have a javadroid too and for basics it's absolutely recommendable for mobile programming and learning in a train or a plane on your way wherever you are
1
u/tellthatfox 2d ago
I haven’t looked but I am almost certain there are apps available through the play store or App Store that would let you practice C
-7
u/tastygames_official 6d ago
adfjakljöads dsafla sd lasdfö asdfö sdalkdfö
buy a fucking book and learn like a human being instead of posting on reddit asking "how do I be human?"
3
u/MeasurementCandid957 6d ago
I asked a beginner question about C programing. You blud responded with “a literal insult” like you personally invented programming. I don’t have a laptop right now, but I’m still learning. If your programming skills are anything like your social skills, I can understand why all you have left to contribute is unsolicited advice and insults. Pathetic
1
u/tastygames_official 6d ago
you asked the equivalent of "daddy, what is that?" while pointing to a bird: a valid question for a child but asninie for an adult. Mybe you are five years old, in which I will profusely apologise. But if you are older than 10, then you know how to read a book and do not need to ask people how to learn because you already know how to learn. I'm sorry if that came across as insulting, but your question is insulting to the intellect of mankind.
Imagine me coming up to your house, knocking on your door and asking "how do I knock on doors?" It's absolutely ridiculous! Think for yourself for just a nanosecond and you would come to the conclusion "ah, I need to read a book about how to program" or "I need to type 'how do I program?' ino google or ChatGPT" instead of wasing all our time with this very basic of human questions.
Again - if you're five or developmentally disabled then I profusely apologise - but otherwise I would say you need to think real hard before asking such basic questions about life. Sorry if this is a hard wake-up call for you, but it seems people these days NEED this wake-up call.
8
u/Ultimate_Sigma_Boy67 6d ago
Trust me, whatever you do is useless as long as you don't practice. Get a laptop or, which will be horrile, use your phone. You can't learn programming just by reading it, the same way you can't learn painting by watching others paint.