How Can I Find Tricky C Programming Questions to Practice?

0
0
Asked By TechGuru42 On

Hey all! I'm just starting out with C and while I've grasped the basics well enough, I often find that exam questions catch me off guard. For instance, I recently learned that `printf` returns the number of characters printed, but I didn't realize that until it came up in my exams. I also encountered the ternary operator in a confusing way:

```c
c = (a > b) ? a = b : b = a;
```
I didn't know that the assignment `b = a` would also set the value of `c` to `b`! And when I saw something like this:

```c
int a = 1;
if (a = 0)
```
I wasn't aware that this would assign `0` to `a` before evaluating the condition.
So, I'm looking for resources or websites where I can find challenging and tricky questions like these to practice along with tutorials that would help me deepen my understanding of C. Thanks in advance for your help!

2 Answers

Answered By CodeWhiz88 On

It's true that `printf` returning the number of characters is a little obscure and not something you typically rely on. However, checking the return value is considered good practice, even if many don't do it. The ternary operator behaves similarly to chained assignments, which is something to be aware of—assignments can be a bit tricky! As for resources, check out websites like HackerRank or LeetCode; they have lots of challenging C problems you can practice with!

TrickyDevX -

Thanks! I've used HackerRank for practice before, but I'll definitely check out LeetCode too!

Answered By LearnFast101 On

It sounds like you're dealing with some common pitfalls that many beginners face. Your college textbooks should have examples of these kinds of problems—definitely review them! If you're looking for something beyond textbooks, YouTube has a ton of great tutorials! Just search for 'C programming tricky questions'. You might even find practice questions specifically catered to what you’re struggling with.

CodeMaster09 -

What about websites? Any recommendations for good ones aside from textbooks?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.