Chapter1 - Chapter 1 Basic Programming Concepts The diagram...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Ch1 - 1 Chapter 1 - Basic Programming Concepts The diagram below illustrates the essence of computer programming. The computer is a mindless robot which simply follows the instructions given to it. It follows these instructions very quickly, and very accurately, but that’s all it does. It doesn’t think. All the thinking is done by the programmer. He (or she) considers the problem to be solved, devises a suitable set of instructions (an algorithm ), and gives these instructions into the computer. The computer then follows (executes) the instructions, and, if they are correct, the desired solution is achieved. Thinks about problem, adds inspiration, and produces instructions. Mindlessly follows instructions. Programmer Computer Problem m Instructions Solution It is important to keep in mind that computers are dumb (dumber than even your average professor). While they may sometimes look very intelligent indeed (e.g. “Deep Blue” – IBM’s famous chess playing computer), this is just because they are following a very clever set of instructions. Computers simply do what they are told to do. If they are given silly instructions, they will produce silly results. Hence the saying: “garbage in – garbage out”. The basics concepts can be illustrated with examples from everyday life. Imagine, for example, that we are hungry (a definite problem). We think about the issue, decide that we would like some muffins, and come up with a suitable recipe (a set of instructions). The recipe is given to a cook who mindlessly follows it and (presuming that the recipe is any good) we wind up with a delicious batch of muffins (a solution to our problem). As can readily be seen by comparing the diagram below to the diagram above, the entire process is analogous to computer programming. The only key difference is that we have “programmed” a cook rather than a computer. Thinks about problem, adds inspiration, and produces instructions. Mindlessly follows instructions. Us Cook Hunger (problem) Recipe (instructions) Muffins (solution)
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Ch1 - 2 Our recipe might be: - Obtain 2 cups flour, 3 teaspoons baking powder, 1 teaspoon salt, 2 tablespoons sugar, 2 eggs, 1 cup milk, and ¼ cup melted butter. - Beat the eggs well. - Stir the flour, baking powder, salt, and sugar together. - Combine beaten eggs, milk and melted butter, and then add all-at-once to the dry ingredients. - Stir quickly until ingredients are just mixed and batter is lumpy. - Fill greased muffin pans 2/3 full and bake at 400 ˚ F for 20 minutes. “Garbage in – garbage out” certainly applies. Suppose that, due to a small typographical error, the recipe given to the cook called for the muffins to be baked at 400 ˚ F for 200 minutes. The results would not be what we expected and would certainly not be much of a solution to our problem. Arguably most real cooks would spot such an outrageous mistake but in order to preserve the analogy between this example and computer programming it must be assumed that the cook does not think at all, but instead mindlessly follows the recipe he is given. Never forget that computers do not think at all
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern