Lab 1.1 Exercise Answers
This section gives you some suggested answers to the questions in Lab 1.1, with discussion related to how those answers resulted. The most important thing to realize is whether your answer works. You should figure out the implications of the answers here and what the effects are from any different answers you may come up with.
What is a program?
Answer: A computer program comprises instructions that direct the actions of the computer.
Without using a computer program to fulfill this responsibility, what potential problems do you foresee in generating this report every day?
Answer: Programs help us with repetitive, time-consuming, and error-prone tasks. If you do not have a program that helps you create this report, it might take you a whole day to collect the needed information for the report and perform the needed calculations. As a result, you will not be able to concentrate on your other responsibilities. In addition, sooner or later you will probably make mistakes while creating the report.
Based on your observations in question b, how do you think a computer program would make that task easier?
Answer: Using a program guarantees fast retrieval of needed information and accurate results, assuming that the program does not contain any errors. Furthermore, once a program is created, the same set of steps is repeated on a daily basis. Consequently, a well-written program is not susceptible to human frailties such as typographical errors or the accidental exclusion of a formula.
What is a programming language?
Answer: A programming language is a set of instructions consisting of rules, syntax, numerical and logical operators, and utility functions.
What type of programming language is this code an example of?
Answer: This is an example of a machine language.
Machine language is understood directly by the computer. Each statement in machine language is represented by a string of zeros and ones.
This example illustrates the nonintuitive nature of machine language. However, a computer can read these instructions directly and execute them instantly. You can see that creating a program in a machine language can be a slow and tedious process. To facilitate program creation, programmers use higher-level languages that are closer to human language.
What type of programming language is this code an example of?
Answer: This is an example of an assembly language.
Assembly language uses mnemonic symbols to represent the binary code of machine language. Each assembly instruction is directly translated into a machine language instruction. You may notice that assembly language is slightly easier to understand than machine language.
What type of programming language is this code an example of?
Answer: This is an example of a high-level language.
Programs created in high-level languages are portable. They can be moved from one computer to another because a high-level programming language is not machine-specific. High-level languages must be translated into machine language with the help of an interpreter or a compiler.
1.1.2 ANSWERS
What is an interpreted language?
Answer: An interpreted language is translated into machine language with the help of another program called an interpreter. The interpreter translates statement in the program into machine language and executes it immediately before the next statement is examined.
What is a compiled language?
Answer: A compiled language is translated into machine language with the help of the program called a compiler. Compilers translate English-like statements into machine language.
Which do you think will run quicker, an interpreted or a compiled program?
Answer: Generally, interpreted programs run slower than compiled programs.
As you observed earlier, an interpreted program must be translated into machine language every time it is run. A compiled program is translated into machine language only once when it is compiled, and then it can be executed as many times as needed. As a result, an interpreted program runs slower than a compiled program.