COMP122
Week 1 Homework
Part 1: Complete the following problems.
1. What is machine code? Why is it preferable to write programs in a high level language such as C++?
A: The machine code is the language which the computer hardware understands and executes. It is preferable to write programs in a high level language such as C ++ because it is much easier to understand and learn this machine language.
2. What does a compiler do? What kinds of errors are reported by a compiler?
A: A computer translates high level language into machine code. While a compiler reports errors such as syntax errors.
3. What does the linker do?
A: A linker takes one or more machine code modules generated by a compiler and combines them into a single
…show more content…
- double payrate = 12.50; e. Copy the value from an existing int variable firstNum into an existing int variable tempNum. - tempNum = firstNum; f. Swap the contents of existing int variables x and y. (Declare any new variables you need.) - inttmp = x; - x = y; - y = tmp; g. Output the contents of existing double variables x and y, and also output the value of the expression x + 12 / y - 8. - cout << x << “ “ << y << “ “ << x + 12 / y – 8 << endl; h. Copy the value of an existing double variable z into an existing int variable x. - x = static
5. Given the following variable declarations:
int x = 2, y = 5, z = 6;
What is the output from each of the following statements?
a. cout << "x = " << x << ", y = " << y << ", z = " << z << endl;
A: x = 2, y = 5, z = 6 b. cout << "x + y = " << x + y << endl; A: x + y = 7 c. cout << "Sum of " << x << " and " << z << " is " << x + z << endl; A: Sum of 2 and 6 is 8 d. cout << "z / x = " << z / x << endl; A: z / x = 3 e. cout << "2 times " << x << " = " << 2 * x << endl; A: 2 times 2 = 4
6. Given the following variable declarations:
int a = 5, b = 6, c;
What is the value of a, b, and c after each of
First let us take a look at computer programming. This element takes on different program designs created by engineers and uses one of several different programming languages to write executable code that computers can read. Programming is the source for
2) Write the following as an algebraic expression using x as the variable: The sum of a number and -8
&& // is a logical and operator that if both the operands are non- zero, then the condition becomes TRUE.
For each of the two programming problems, create a program using Visual C++.Net. Make sure to capture a sample of your program's output. The best way to do this is to click on the console window you want to capture and then press the Alt and PrintScreen keys at the same time. Then paste your captured screen image into a Word document. For each of the two programs, put the screen capture followed by a copy of your source code into your Word document.
- Compilation a program written in the high-level language and used as an input to a translator program
We are using two FOR Loop to traverse the input and create a 2 dimensional array for printing the output.
In the above assignment statement, the variable x holds the string “Python”, y holds the float 127.5, and z holds the integer 54.
using printf() (only one is allowed) and arithmetic operators where slope is 4, x coordinate
Each programming language uses a piece of software, called a compiler or an interpreter, to translate your program code into machine language. Machine language is also called binary language, and is represented as a series of 0s and 1s. The compiler or interpreter that translates your code tells you if any programming language component has been used incorrectly. Syntax errors are relatively easy to locate and correct because the compiler or interpreter you use highlights every syntax error. If you write a computer program using a language such as C++ but spell one of its words incorrectly or reverse the proper order of two words, the software lets you know that it found a mistake by displaying an error message as soon as you try to translate the program.
A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code). The most common reason for wanting
1) I am new to programming and wanted to know if you could review what I did for this assignment to see if I am on the right track. I'm not sure if you will be able to open it if I send it to you from a computer that does not have Corvid on it.
The purpose of the programming languages as Coded language to write information by programmers that a computer could understand to do what the programmer wants. A computer language is used binary ( '1 ' and '0 ') code as call the machine language that a computer can execute instructions quickly without any translator or interpreter program, but is complicated. The high level languages such as C++ and java are very simpler for use, but it need to another program to transfer a high-level code into a computer language, for this are slower. There are many of programming languages are being always developed.
Programming languages are a set of instructions or grammatical rules, which are used to make applications and software on computers (Beal). There are many programming languages, which are used extensively in modern day computer science, some of which are C++, Python, HTML, FORTRAN, Ruby and Pascal. They were initially created by computer scientists to simplify calculations and to perform repetitive tasks with ease. These languages are one of the core components of a computer and they facilitate the creation and functioning of complicated applications and softwares.