Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Programming difficulties

  1. May 12, 2007 #1
    I am studying computer science and i have just finished my first year. We had a little bit of C language. Now i can grasp the theory part of the language like the syntax and the components of the language, but i can't seem to be ale to write programs. I mean i cant form the correct algorithm or the strategy to solve a problem.
    Any suggestions, on how i can write a real program?
    Thanks.
     
  2. jcsd
  3. May 12, 2007 #2
    Try. Make mistakes and learn from them.
     
  4. May 12, 2007 #3
    Maybe you won't like this, but try studying more Math.

    The original programmers were all Mathematicians, and the same logical step-by-step process is what is useful for programming.

    Let say you are starting from A, trying to get to B. A good way to think is to find some Z, such that "if I had Z, I could get to B". Then declare all the variables you need for Z, and try to get from A to Z.

    Declaring variables helps me as a first step.
     
  5. May 12, 2007 #4

    -Job-

    User Avatar
    Science Advisor

    In programming, start with design and then implementation.

    The design phase doesn't have to be concerned with programming at all. You approach the problem as if it had come up in your daily life.

    Naturally, the process of sorting an array of n numbers for instance, is equivalent to the process of sorting a collection of n books by author. Once you have an approach that enables you to sort the n books you can use the same process to implement an algorithm that sorts an array of n numbers.

    The better you can visualize and relate to a problem the easier it will be to solve.
     
    Last edited: May 12, 2007
  6. May 12, 2007 #5
    Whant kind of mathematics? Discrete mathematics?
     
  7. May 12, 2007 #6
    Thanks a lot, i will keep all the suggestions in mind and think over them. I must admit, i am a little scred by my career decision, will i be able to meet what is demanded from me?
     
  8. May 12, 2007 #7

    symbolipoint

    User Avatar
    Homework Helper
    Education Advisor
    Gold Member

    Crosson's suggestion is useful but by itself may not be enough. Shaan Aragorn, you are not well conditioned yet and have not learned enough how to think critically and analytically. You are in the process of getting this conditioning right now. In your daily life as student and maybe as a worker if you have a job, use "-job-"s suggestion, and actually look for programs to create which are not simply assignments for your programming course.

    Always try to make flow charts to straighten your thinking about how to manage a solution to a programming exercise; carefully study the algorithms and flowcharts shown in your textbook, too. Remember, if your flow chart is good, then you translate the flow chart directly into code (unless C works too differently than other languages).

    Even if you barely pull a C grade in your course, you may relearn programming later and be able to create a very helpful little program later for your own use or for someone else's use.
     
  9. May 12, 2007 #8
    Is the main problem in making abstractions (e.g. object orientation, functional decomposition) or in algorithm development?
     
  10. May 13, 2007 #9
    I do not get by what you mean abstractions, forgive my ignorance.
    But algorithm development is a major problem for me.
     
  11. May 13, 2007 #10

    symbolipoint

    User Avatar
    Homework Helper
    Education Advisor
    Gold Member

    Maybe you could have told us what you are studying. Many years ago, beginning programming students did not study that object oriented stuff. They focused on flowcharting, defining variables, developing algorithms, and learning one or two particular languages, which would likely had been BASIC, FORTRAN, or PASCAL. A first programming course was very difficult for some students.

    For you, shaan aragorn, STRUGGLE with it; you may need to repeat your course, but (1) keep your textbook and study on your own after the current term ends, and (2) the effort will be worthwhile; you may find programming skill to be very useful in the next several months, even if you did not master all of the material in your current programming course.

    I struggled with an older form of BASIC, barely passing, and then used the language a couple of years later in another course. I only used as much of the language as necessary for this later course. More recently, I have improved in my BASIC programming skill (and have no worries about learning BASIC for a grade anymore).
     
  12. May 15, 2007 #11
    I have just completed my first year in computer science. In it, among other subjects like

    math we had one paper based on the C language. But i think i am going to fail in that

    subject. So i have to get strong in it before my next attept which is approx 4 months away.

    Also, this sem i'll be having data structures based on C and the C++ language the next sem

    to that.
    The main thing i cannot understand is problem solving. That includes algorithms.
     
  13. May 15, 2007 #12
    Whenever something is a super struggle, I look for for other possible causes of the difficulty.

    For example I was trying really hard for over a month to keep my ankle aligned perfectly while running, but I wasn't making any progress. Then I stretched at a specific muscle in my lower leg and my ankle went straight automatically, from then on. I had talked to many personal trainers that would repeat the useless "try to keep your ankle straight" but what I really needed was to work on something indirectly related.

    If programming is that much of a struggle, I am sure the problem is coming from indirect areas. You say your problem is algorithm development, so the traditional approach would be to read books of algorithms an practice lots of problems. We already know that this would be more of the same struggle, and along the lines of my ankle story it could add up to very little improvement.

    Now discrete math is too much related to algorithms, we already know that is something that you struggle with. Do something totally different that still builds up the analytical logical part of your mind, like mind puzzles or geometry or symbolic logic or anything else where you enjoy using the analytical-logical part of your brain. The key is that you are having fun while doing it.

    To be honest, your plan for next year is overly ambitious. The data structures class will be very difficult without a good understanding of the first year material. I am sure it is very important to you to continue on in your studies, so my suggestion is to find a good tutor, unless you are an ace at self-study.
     
  14. May 16, 2007 #13
    thanks

    Thanks Crosson.
    I feel you are very true about discrete math and puzzles. I struggled a lot in those areas too. I realize that I never really stick with a problem or a puzzle long enough to solve it. I'll have to change that. So how much time do you think I'll require to write a perfectly good program?
    Also private tutors here are very expensive. Altough I may be able to manage a tutor who teaches 20 to 30 students at a time.
     
  15. May 16, 2007 #14

    symbolipoint

    User Avatar
    Homework Helper
    Education Advisor
    Gold Member

    Shaan Aragorn,

    Do you mean that you are just studying a computer science course, or are you using computer science as a major field of study? If you mean that c.s. is your major, then you should change your major field. Your efforts at studying your current programming course would not have been a waste; some of the skills and concepts may be slowly creeping into your general proficiencies.
     
  16. May 16, 2007 #15
    study mathematics.
     
  17. May 16, 2007 #16

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    The great thing about computers is that they do exactly what you tell them to do.
    The worst thing about computers is that they do exactly what you tell them to do.


    One thing that will help is that when you write a line of code, to try and understand exactly what you are telling the computer to do.
     
  18. May 17, 2007 #17
    hurkyl: shouldn't the word "tell" be replaced with "{code,program}" hehe.
     
  19. Jun 2, 2007 #18

    rcgldr

    User Avatar
    Homework Helper

    My experience with many real life programs has been that developing algorithms is a small part of programming, and most of the time is spent simply breaking up a known algorithm into the small steps supported by the programming language involved. Sometimes peformance is important and optimizing the code and/or algorithm is involved.

    Maybe it would help to be given a simple algorithm, implement it in C, and then think about ways to improve it.

    For example, input a line of text (or just delcare it in the program), then count the number of vowels in the text (the sum of all the a, e, i, o, and u that occur in the text). Once the number of vowels is known, is there a quick way to determine the number of non-vowels?
     
  20. Jun 15, 2007 #19
    Hi shaan_aragorn
    I am doing C++ for almost two and a half years, though I am still at school.
    The problem you are facing is very common, and students have to tackle it on their own. One can learn all the aspects of a programing language in no time, but the real problem is- algorithm development. I am nobody to advise you, but the way I did it was to read the maximum number of examples given in the course book. Read each example, and each line of code in it carefully and ask yourself: What is this code supposed to do?
    There may be instances where the code is a compact one and difficult to understand. Try to break it into simpler codes.
    After you have completely grasped the algorithm of the program, close the book and try to write it yourself without peeking into the book.
    No doubt it will take time, and sometimes it gives you hell of a frustration. But once you have understood these examples, you feel a little more confident. Now try to attempt the exercise questions yourself. Here also, attempt each and every question.
    A major thing to remember here is to try the maximum number of programs on your computer. After you have written a code in the compiler/interpreter debug it line by line, and insert codes which can help you understand how the computer solves the problem.
    For example:
    C++

    for(int i=0;i<10;i++)
    {
    if(i%2==0) cout<<"even";
    else cout<<"odd";
    }

    The computer will run the code written in braces 10 times, each time increasing the value of i by 1 by the computer. If i's value is divisible by 2, your monitor will display "even", otherwise it will display "odd".


    Doing things in this way will lay down a firm foundation for you to build on. The programs given in introductory chapters are such that you have got to grasp them completely. After that, though the subsequent chapters have new concepts, but they are not so difficult if you have done your homework the right way.

    Regarding the type of problems, there are 1) Mathematical problems: e.g. categorizing numbers as prime or composite, finding the factorial of a number etc.
    2) Non-mathematical problems ( though there is some basic mathematics involved here.): converting lower-case characters to upper-case, finding out vowels and consonants, or whitespaces etc.

    Both types of problems need practice. However, mathematical problems are comparatively easier: you have already got formulae for them. (Here again, the difficult part is making the system understand those formulae by suitable coding.)

    It all depends on how much time you can devote, and how much time you are left with. But beware! Never try to start the next chapter without completing the previous one ( It will just make the situation more desperate for you). And yes, hard work pays greatly in programing: the harder you strive, the better you become. I am sure you will soon overcome this problem.

    I hope my post was helpful in some way.

    regards
    Mr V
     
    Last edited: Jun 15, 2007
  21. Jun 19, 2007 #20
    Well, to tell the truth, i am not a very good programmer. But i am able to program well. I do a lot of errors and so on. But the thing that helps me survive is trial and error. I experiment a lot and see that are the differences. I try to write something one way or the other and save the good pieces of codes that are somewhat long which could be useful later and use that code again when needed.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Programming difficulties
  1. Root programming (Replies: 3)

  2. Difficulty Compiling (Replies: 3)

  3. Explain this program. (Replies: 3)

  4. Programming languages (Replies: 16)

  5. HMI programming (Replies: 1)

Loading...