.

Wednesday, November 27, 2019

Computer Languages Essays - Programming Languages, C, Source Code

Computer Languages Despite having very little knowledge of the world of computer programming, I have come to believe that C++ is currently the programming language of choice. If that is the case, it would be easiest to only learn C++ and to ignore the other programming languages. However, computer programmers should not ignore the other programming languages for at least three important reasons. One, some computers might not accept C++ as a programming language. Two, there may be features of other programming languages that are superior to C++. Three, there are many useful programs written in languages besides C++ that can only be modified with knowledge of those other languages. For these reasons, it is important that all good programmers are able to adapt to other programming languages. The intention of this lab is to create computer programmers who are able to adapt to many different programming languages. Section I: Examining High-Level Programming Languages Introduction to Section I In this section, six previously-prepared programs, written in the programming languages Fortran, Pascal, and C, are looked at and compared. For each program a hypothesis is formed about the function the program serves, and the way in which the program performs that function. Also included in the hypothesis is a description of what makes the programming language easy or difficult to read. Testing the hypothesis is simply a matter of compiling and running the program using a variety of inputs. For each experiment in this section, I wrote out a hypothesis for the program before I tested it. Then, after testing the program, I prepared a conclusion about how the program works. Experiment 1: oddeven.f Hypothesis I believe that the Fortran program will first ask for how many numbers are in your list of numbers. Then it will read in all the numbers in your list, one at a time and tell you if the number that you just entered is even or odd. The program will keep track of how many of your numbers are even and how many are add. After you have entered in all the numbers in your list, it will print out how many of your numbers are odd and how many are even. The Fortran language is fairly easy to understand, so forming my hypothesis of what the program would do was not a very difficult task. Most of the commands used in Fortran are words that represent their function like "PRINT *," "READ *," "IF," "THEN," and "END." On the other hand, Some of the commands used, like "DO 11 I =1" and "MOD," are vague and not easily understood. The print commands are especially helpful for checking my hypothesis. Because the print commands were written to give the user a good idea of what the program is doing, they also helped me figure out what the program is going to do. Conclusion The program behaved pretty much as I thought it would in my hypothesis. First the program instructed me to "Enter length of list." Then I was to enter in the numbers in my list one by one, and after each number the computer either responded with "[number] is even" or "[number] is odd. After I had entered in all the numbers in my list, the program printed out how many of my numbers were even and how many were odd. The program did not even mess up when I entered in decimal numbers, instead it just truncated the number and proceeded as if the truncated number was the number to be evaluated. Unfortunately, the program did label zero an even number, which it isn't, but that is a fairly minor mistake. Also, I happened to have noticed that if I was entering numbers, and screwed up, the program wouldn't let me delete the last number I entered. This is kind of a drawback, but I don't know how one would go about fixing that problem. Experiment 2: weather.p Hypothesis To begin with, the program will print the following "Good day. My name is Ronald Gollum. I'm stuck in this box until quitting time. Please chat with me about the weather. Is it raining now?" The computer will store the user's answer to this question under a variable titled "Ans." If your answer to the question is Y or y, then the computer will store the value true under the Boolean variable titled "Raining." If your answer to that question is not Y or y, then the program will store the value False in "Raining" and then print the message "Too bad.

No comments:

Post a Comment