Computer Languages

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.

Best services for writing your paper according to Trustpilot

Premium Partner
From $18.00 per page
4,8 / 5
4,80
Writers Experience
4,80
Delivery
4,90
Support
4,70
Price
Recommended Service
From $13.90 per page
4,6 / 5
4,70
Writers Experience
4,70
Delivery
4,60
Support
4,60
Price
From $20.00 per page
4,5 / 5
4,80
Writers Experience
4,50
Delivery
4,40
Support
4,10
Price
* All Partners were chosen among 50+ writing services by our Customer Satisfaction Team

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. We need rain.” No matter what was entered previously, the program will print the message “Do you think it will rain tomorrow?” The program will replace the old value of “Ans” with the answer to this new question. If the answer is Y or y the program will print “I’ll worry about that tomorrow.” If the value stored under “Raining” is true, the computer will then print the message “It’s finally quitting time! Good bye. You brightened up this rainy day.” Otherwise, the program will write, “It’s finally quitting time! Good bye. I want to work on my tan.” For Pascal, like for Fortran, most of the commands are words that represent something – commands like “begin,” “writeln” (I am guessing that ln stands for line), “readln,” “if,” “then,” and “end.” In Pascal, though, the commands that store and interpret variables are not worded as I would expect them to be.

For example, one command was “if not Raining then [..]”. I would expect a computer to have an easier time with a more defined command like “if raining = false then [..].” That Pascal command was probably someone’s attempt to make the program more like plain English. I also noticed that the words in Pascal are not capitalized like in Fortran. In general, Pascal appears to be much more like normal paragraph then Fortran. Tests Input Ouput at end Input Immediate Output Y You brightened up this.. Y I’ll worry about that tomorrow.

yes You brightened up this.. YES I’ll worry about that tomorrow N I want to work on my tan. N none No I want to work on my tan. NO none Yahoo You brightened up this.. YOyO I’ll worry about that tomorrow Hallo I want to work on my tan.

Ween none 1999 I want to work on my tan. /?? none Conclusion The program ran pretty much like I said that it would in my hypothesis. The only real difference is that the program reacts to any word beginning with a Y or a y, like it is a Y or a y. That is because only the first letter of any word that is entered in is stored. When I entered the word yummy, the computer treated it like I had entered an affirmative y.

In the same respect, when I entered the completely unrelated word Odd as a response, the computer treated my answer like a negative response, and later responded like I had said no. I tried answering with a bunch of different responses including numbers, symbols, and even Pascal commands, but in every case the computer treated my answer like a negative response, unless my response began with a Y or a y. Experiment 3: triangle.c Hypothesis The program will ask for three side lengths for a triangle. If all three side lengths are equal, the program will print “Equilateraln”. If two side lengths are equal, the program will print “Isoscelesn”. Otherwise, the program will print “Scalenen”.

The program will repeat until 0 is entered as a side length, and then it will stop. Trying to guess what this program is going to do was really difficult. This program is much longer than the first two, and many of the commands seem to be unnecessary (commands like “#include”, “int clasify,” “break,” and “scanf”). The commands are very difficult to read, and involve complex syntax (What the heck is the command “scanf (“%If%If”, “&s2″, )” supposed to do?). The only reason that I have any idea what the program is going to do is because of the print statements, which print what the user needs to know.

However, even within the quotation marks of the print statements there is C syntax, like in this command “printf (“Isosceles/n”)”. The if commands, at the end of the program, led me to believe that the computer just compares the lengths to see whether or not they are equal to each other. Tests Inputs Output 13, 13, 13 Equilateral 12, 16, 12 Isosceles 100, 90, 1 Scalene 45.8, 57.3, 45.8 Isosceles -99, -99, -99 Equilateral Inputs Output -18, -96, 5, -18 Isosceles -56, -56, 38 Isosceles -89, 89, 98 Scalene -9, -9.5, 9.5 Scalene -11.25, -11.25, -11.25 Equilateral Inputs Output 76000, 7600.1,7600.1 Isosceles 8600.1, 8600.2, 8600.3 Scalene 17, 0 , 89 (ends) 0, 89, 123 (ends) -119, 245, 0 (ends) Conclusion Surprisingly, my hypothesis was fairly close to being right. The computer instructed me to enter three lengths. After I entered three lengths the computer told me what kind of triangle those lengths corresponded to (scalene, isosceles, or equilateral). The program did not print isosceles/n etc..

like I hypothesized it would, instead it printed isosceles. When I entered zero as a side length the program ended just like it was supposed to. The program would accept negative lengths, despite the fact that a negative length is not possible. The only stipulation the program had to separate the 3 different kinds of triangles is that the correct number of side lengths was equal. Experiment 4: Language Comparison Before Running the Programs C is a very difficult programming language to understand. C commands are full of syntax that does not seem to represent the plain English equivalent of the commands. C also requires all sorts of symbols, parentheses, and brackets, which makes the program look cluttered and cryptic. The bright side to the symbols, parentheses, and brackets is that the programmer does not have to follow any specific format. Compared to the C program, the Fortran program is very easy to read.

Fortran reads almost like a normal language algorithm. The commands used are REAL, PRINT *, READ *, and END. The programmer still needs to know some syntax, but not nearly as much as C. Each line contains one complete command, and nothing else. There are no brackets, and parentheses cluttering up the program.

Pascal is very similar to Fortran, except that it is a little bit more complex and cluttered. Each line in Pascal has a semicolon at the end, whereas Fortran did not need those semicolons. Pascal also has colons and parentheses within the commands that Fortran does not have. Pascal is still much easier to read than C. After Running the Programs When I ran them, the three programs were almost identical.

The only difference between the three programs was the way the final print was formatted. Pascal represented the numbers in scientific notation with 8 decimal places, while Fortran and C represented the numbers in standard notation with about 6 decimal places. Fortran also had large spaces before and after each number, whereas C …