Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone..!!

Hi, I'm a newbie trying to learn to code and the biggest problem I'm facing in learning is my inability to think about the right solution to the problem given in the exercises (from the book I'm learning) and this makes me feel dumb.

I'm learning C# and this is the first language I picked to start with. Although I understand the concepts like Loops, For Loop, While Loop and Arrays I find it hard to develop logic utilizing them. I'm confused, I mean is it just me who is facing this problem or everyone who learns a language first time faces it.

I also want to know is there anything specific or may be an accepted principle or procedure that the programmers follow while solving problems and developing programming logic? Is there something that I can do to improve my thinking capability while programming?

By the way, the book I'm learning from is "Fundamentals of Computer Programming with c# - Nakov eBook 2013". I like the book and the concepts are also explained in a good way but maybe you guys can suggest something better.

I'm pasting the Index part of the book for you guys to have a look.

Chapter 1. Introduction to Programming.........................................69
Chapter 2. Primitive Types and Variables ......................................111
Chapter 3. Operators and Expressions...........................................139
Chapter 4. Console Input and Output ...........................................165
Chapter 5. Conditional Statements..............................................195
Chapter 6. Loops ..............................................................211
Chapter 7. Arrays .............................................................235
Chapter 8. Numeral Systems ....................................................265
Chapter 9. Methods ............................................................293
Chapter 10. Recursion .........................................................351
Chapter 11. Creating and Using Objects ........................................385
Chapter 12. Exception Handling ................................................415
Chapter 13. Strings and Text Processing .......................................457
Chapter 14. Defining ..........................................................499
Chapter 15. Text ..............................................................615
Chapter 16. Linear Data Structures ............................................641
Chapter 17. Trees and Graphs ..................................................681
Chapter 18. Dictionaries, Hash-Tables and Sets ................................727
Chapter 19. Data Structures and Algorithm Complexity ..........................769
Chapter 20. Object-Oriented Programming Principles ............................807
Chapter 21. High-Quality Programming Code .....................................853
Chapter 22. Lambda Expressions and LINQ.........................................915
Chapter 23. Methodology of Problem Solving .....................................935
Chapter 24. Sample Programming Exam – Topic #1.................................985
Chapter 25. Sample Programming Exam – Topic #2................................1041
Chapter 26. Sample Programming Exam – Topic #3................................1071

I have completed till chapter 6th- Loops. While I can explain the concepts well to anyone but face problem in developing logic. However, this doesn't happen in all the questions but mostly in questions where a loop is needed to be used.

I read at the beginning of the book in the preface / introduction that after completing the chapter no. 19 Data Structures and Algorithm Complexity the person reading this book will develop a good understanding of generating logic, but I highly doubt it in my case.

Please, guys, help me and provide some solution, also please mention what you think about the problem I'm facing, will I gradually develop the thinking skill or should I try some other approach to learn to code.

Please excuse my English as it is not my native language.

What I have tried:

I tried to look for other better resources where I can find some easy to solve problems to develop my confidence, but couldn't find one. I would also be looking forward for some URLs where easy problems are given that increases in difficulty gradually.

Thanks in advance. :-) :-)
Posted
Updated 3-May-18 0:24am

Many things in computing can be difficult to get your head round to start with: it needs your to think in a different, more analytical way than you are probably used to (For some, it's the first time they have ever had to actually think and they have even worse problems than you do!)

Loops are pretty simple, really - they are just a way of doing the same thing many times. For example, you are reading a book to learn about C# - so the process is:
1) Open the book at the start of chapter 6
2) Read the page.
3) Turn to the next page.
4) Is that the end of the chapter?
4.1) No - go back to 2.
4.2) Yes - you have finished chapter 6, now do the exercises.


That's simple - it's something you do every day: reading a chapter (or part of a chpter perhaps).

In computer terms, it's the same thing:
1) Initialize the loop - Open the book at the start of chapter 6
2) Body of the loop - Read the page.
3) Prepare for next iteration - Turn to the next page.
4) Check for completion - Is that the end of the chapter?
4.1) No - Loop round again - go back to 2.
4.2) Yes - Exit the loop - you have finished chapter 6, now do the exercises.

We can write that as a C# for loop:
C#
for (int pageNo = chapterStart[5]; pageno < chapterstart[7]; pageNo++)
   {
   ReadPage(pageNo);
   }
Or a foreach loop:
C#
foreach Page page in Chapters[6])
   {
   page.Read();
   }
Or a while loop:
C#
int pageNo = chapterStart[5]; 
while (pageno < chapterstart[7])
   {
   ReadPage(pageNo++);
   }
Or even a do ... while loop:
C#
int pageNo = chapterStart[5];
do
   {
   ReadPage(pageNo++);
   } while (pageno < chapterstart[7]);
THink about that for a moment, and it may be a little clearer - try comparing loops to "real world" events, and you'll find they are a pretty good match in most cases!
 
Share this answer
 
Comments
Mohit Tomar 2-May-18 6:49am    
What about Data Structures and Algorithms? Learning it would improve logic development or not? And is there something programmers follow like some principles or best practices that make their job easier while they are programming?

I know that I have just started with coding and I should be more patient with my speed in grasping new concepts. But just thought that I should ask it.
OriginalGriff 2-May-18 7:10am    
You can't really "learn algorithms" as such - a algorithm is a way of doing something, exactly like a recipe for a cake: you might get a dozen different recipes for "making a chocolate cake" - heck, I know a couple of dozen - and each of them will treat the ingredients a bit differently, and end up with a different cake that is still very recognisable as a chocolate cake!

It's the same with algorithms: there are for example at least 7 basic algorithms for sorting values.
Bubblesort
Selection Sort
Insertion Sort
Shellsort
Heapsort
Mergesort
Quicksort
And they all have variants as well. You'll meet some of these as you move through the course, I imagine.

And "learn data structures" is a difficult idea as well, made worse by the fact that there are more different data structures than there are different programs! :laugh:

Don't get hung up on "names" for the moment - what's trying to happen is a change in the way you think, and that takes time. And it's very important to get the change "settled in" before you try to leap ahead to more complicated (read "more interesting") subjects or you won't be able to understand them.

Take your time, reread the book to make sure you fully understand the material so far, and don;t be in a hurry to move on - it takes time to learn new things, and each of us is different in that.
Think about it: when you learned to ride a bicycle, you fell off a lot (or relied on the stabilisers) until your mind worked out how to balance everything and you were fine. (But you still can't explain to someone else how you balance a bike, can you?)
Mohit Tomar 2-May-18 8:00am    
Thanks for your efforts in trying to help me out. I like the Bicycle example, that one fits in my situation. I know I'm hurrying a little bit, I should slow down now, and after your reply, my mind is at ease. Coding is totally a new concept for me. I will give some time to myself to slowly absorb it.

Thanks for your help..
OriginalGriff 2-May-18 8:04am    
You're welcome!
To be able to approach problems and determine a way through them is a valuable skill - and the good news for you is that it can be learned, and it gets easier with practice.

There are some free resources out there that might help you e.g. How to think like a programmer — lessons in problem solving[^]

There are also a lot of books: e.g. How to Think Like a Programmer: Problem Solving for the Bewildered: Problem Solving for the Bewildered: Amazon.co.uk: Paul Vickers: 9781408065822: Books[^]

Note I can't recommend the links above as I haven't used them, they are just examples that I found.

However, a book I found invaluable and can recommend, was The Pragmatic Programmer: Amazon.co.uk: Andrew Hunt, David Thomas: 8601404321023: Books[^]

Good luck in your journey
 
Share this answer
 
Comments
Mohit Tomar 2-May-18 8:02am    
I have checked the link. I found all the links useful. Thanks :-) :-)
You have to know that you can do pretty much anything in any language, simply some languages are harder for beginners because there is more pitfalls to handle.
You need to master a set of techniques that are the basis of the job and are not linked to a language.

Advices:
- Start with an easy/safe language: VB, Java, C#, not C or C++. I do not recommend to start with Python either because of the usage of indentation.
- Read documentation / Follow tutorials (a lot of them)
- Start with tiny/useless projects, the purpose is to learn programming, not doing something useful.
- Start with console mode programs (no fancy graphics, no mouse)
- Learn debugger (an incredible learning tool)
Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
- A problem ? Google is your friend.
- Learn Algorithms and Data-Structures.
- Learn Boole algebra
- Learn one or more analyze methods, E.W. Djikstra top-Down method is a good start.
Structured Programming.pdf[^]
https://en.wikipedia.org/wiki/Top-down_and_bottom-up_design[^]
https://en.wikipedia.org/wiki/Structured_programming[^]
https://en.wikipedia.org/wiki/Edsger_W._Dijkstra[^]
https://www.cs.utexas.edu/users/EWD/ewd03xx/EWD316.PDF[^]
- Learn SQL
- Learn Databases design and Administration
Introduction to database design[^]
1NF, 2NF, 3NF and BCNF in Database Normalization | DBMS Tutorial | Studytonight[^]
- Learn Regular Expressions

Interesting link:
stanford.edu: Learn to Program[^]

There is no shortcut to knowledge, no one can learn for you, you are the only one that can do it.
Remember the exercises and little projects are not here to make something useful, they are here to teach you programming.
 
Share this answer
 
Comments
Mohit Tomar 3-May-18 5:24am    
Thanks for the links :-)
I have a question though. Being a student of Arts I have very less knowledge about high-level mathematics as used in computers. I have studied mathematics till 10th standard in High School but never studied mathematics during graduation. Whenever I check the Wikipedia page of any computer-based term I see that the wikipage is filled with mathematical concepts, that I, of course, don't understand. :-)

Would someone like to make any suggestion as to what mathematical concepts I should be aware of or learn/read? I can start from very basics because as far as time is concerned I have a lot of it because I'm learning to code in my free time.. :-)

All I want is to have an in-depth understanding of computers, computer codes and coding.

Thanks in advance. :-)
 
Share this answer
 
Comments
CHill60 3-May-18 8:05am    
Avoid posting further questions as "solutions" - I can see why you did it in this case but it is better to use the "Have a Question or Comment" link or "Improve Question" link.
However...
Not all coding these days requires an in-depth knowledge of mathematics - you probably have enough to get started. Set-theory is probably going to be important though - have a read of this CP article that explains the concept with pictures rather than mathematical symbols - Visual Representation of SQL Joins[^]
An understanding of things like Permutations and Combinations is probably also going to be useful.
For most other things I would suggest researching them as you need them, otherwise you will get so caught up in learning this stuff you'll miss out on the fun of coding :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900