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++? Machine code it the language that the computer understands. High level languages are better because they are easier to understand and work with. 2. What does a compiler do? What kinds of errors are reported by a compiler? A compiler translates one computer language into another. It also pics up errors in the program being put together. 3. What does the linker do? A linker takes multiple object files, and turns them into an executable program 4. What is an algorithm? The list of instructions to complete a task on a program 5. Bob enters a pizza shop and notices …show more content…
21 % 5 answer: 1 d. 3 - 5 % 7 answer: 3 e. 17.0 / 4 answer: 4 f. 8 - 5 * 2.0 answer: -2 g. 14 + 5 % 2 – 3 answer: 12 h. 15.0 + 3.0 / 2.0 answer: 16.0 2. Given the following variable declarations: int num1 = 10, num2 = 20, newNum = 30; double x = 5.0, y = 8.0; Determine which of the following assignment statements are valid. For each invalid statement, explain why it is invalid. Assume that each statement immediately follows the above variable declarations. a. num1 = 15; b. num2 = num1 - 18; c. num1 = 5; num2 = 2 + 6; num1 = num2 / 3; d. num1 + num2 = newNum; e. x = 12 * num1 - 15.3; f. num1 * 2 = newNum; g. x / y = x * y; h. num2 = num1 % 2.0; i. newNum = static_cast (x) % 5; j. x = x + 5; k. newNum = num1 + static_cast (4.6 / 2); 3. For each of the following lines of variable declarations, identify it as valid or describe what makes the line invalid. Line 1: n = 12; valid Line 2: char letter = ; invalid, don't put “letter” Line 3: int one = 5, two; invalid, “One” and “two” not valid inputs Line 4: double x, y, z; valid 4. Write C++ statements that accomplish each of the following: a. Declare and initialize int variables x to 25 and y to 18. b. Declare and initialize an int variable temp to 10 and a char variable ch to 'A'. c. Add 5 to the int variable x which already exists. d. Declare and initialize a double variable payRate to 12.50. e. Copy the value from an
Please choose from one (1) of the scenarios below. Note: The scenario that you choose in this assignment will be the one (1) with which you continue for Assignment 2.
8. Write a line of code that will declare the variable count to be of type int. Don’t initialize.
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
In the early 70’s, the C program language was developed, which became popular as the programming language used for the UNIX operating system. C is an independent language used for hardware, however with the right design it can be transfer to other computers (Deitel & Deitel, 2011). To liven thing up, in the early 80’s C++ object-oriented program (OOP) was developed. It added objects to the C language, which added more features that made turned objects in to reusable software components that resembles the real
Computer languages are used to create programs and are set of instructions which the computer uses to run a program. There are a lot of computer languages however, they all have different features.One of them is high level language. The advantage of using high level language is that it’s person friendly, so humans can understand it easily as it’s written in text which means that it’s also easier to write and maintain. High level language is also portable and can work across different CPU families and as well as this it supports a wide range of data types. An another advantage of using it is that it programs faster and takes less time to code. A disadvantage of using high level language to program is that it needs to be translated into machine code before it can be executed so that the CPU can run it as computers only use and understand binary data. This can
Programming languages over the years have improved and even changed drastically in their design and capabilities. New languages are created to perform specific tasks that others cannot accomplish each year. By doing so, the creation of these new languages fill specific niches. However, the problem with computer languages is that if you want to construct an easier approach to a task or problem in another language, odds are you must give something else up to accomplish that goal. Which is why there is such a large amount of different and unique programming languages.
01001101 11010010 11001011, Computer programming may sound complicated, but once anyone gets used to it, it is easy to understand. People every day use an electronic device to get tasks done. Those electronics are told what to do when they input a problem or command. To receive a clarification of what Computer Programming is, it is necessary to experience it. It is key to have programmers in this world; programmers have to deal with the complicated parts of the computer. They should be credited for the work they promote on an everyday level. People depend on technology to live because they have learned to adapt to that which is illustrated in everyday lives, History, and soon to be the future.
At first, Java was made for television but that technology didn’t keep up with the innovation. The java language was initially called Oak. Sun Microsystems is the first company to use Java by 1995 . Java’s goals are “familiar, simple, and object oriented”, “secure and robust”, “portable and architecture neutral”, “dynamic, threaded, and interpreted”, and “high performance”. A computer consists both software and hardware. Hardware includes the physical, visible elements of the computer. Software provides the hiding instructions that control the hardware and make it process specific tasks. Having knowledge of computer hardware is not essential to learning a programming, although it can help you understand the effects which programming instructions have on the computer and its components. Bytecode is used for many modern programming languages. The most important advantage of bytecode is the portability. Instead of machine code, the bytecode is run by the Java Virtual Machine. Java Runtime Environment and Java Development Kit are important. You can think of car, a chair, or speaking of computers, a screen when you hear the word “object” in your everyday life. Objects in programming languages usually perform one complex function and have a state and a behavior. The main method is defined as public static void return type. There are two data types in the Java language: primitive and reference. The primitive types are able to contain one simple value whereas reference data types
Numerous amounts of companies and individuals write code to make large and small projects more efficient and easier to fathom. In 2014, Nimrod became a new systems programming language. Nimrod, a new language with a high metaprogramming support, which is programming, but its basically writing code that writes code. Also generics and exception tracking built in, with optional garbage collection. Nimrod is compatible to compile with C, C++, Objective-C, or Java Script. “Generic programming is a style of computer programming is which algorithms are written in terms of to-be-specified-later that are the instantiated when needed for specific types provided as parameters”. In other words, it is occupying or reusing an algorithm and changing its implementations. Garbage collection is an automatic memory management and heap allocation that developments and distinguishes dormant memory block and reallocates storage for recycle. The initial job of garbage collection is to reduce or eliminate memory lost. This will create more memory; thus, running the program more efficient. Nimrod is competing with the top computer language in the world, C programming being the main rival.
Here is some information about computer programs and programmers in general. A compiled language is when you enter code, and the program changes it into machine-specific instructions. An interpreted language code stays the same as the format entered, but is slower because it is interpreted and not converted to make more sense to the computer. Python uses interpreted code, which is one of the reasons it is so easy to use, but also causes it to be somewhat slower. As a job, programmers can earn $22.7K to 65.2K per year. System programmers write and test specialized computer software called operating systems (Wallner). Operating systems (OS) manages computer data and provides common services for computer programs. They also debug, identify why the program is working unreliably, and discuss errors. Professionals need to understand statistics and other higher level math. They need to know technical terms and what different computer symbols mean. Two important parts of a computer are the software and hard drive, but they aren’t the same thing. Software is what a computer can do and what it can run, such as Microsoft Word and even web browsers are software.. The hard
As time passed, computer capacity grew to enable the use of higher-level development tools. These allowed people to define and encode business rules without needing to understand everything down to the basic wiring of the machine. True computer languages and programming frameworks followed.
C++ was produced by Bjarnestroustrupstartingin 1979 at Bell Labs in Murray Hill, New Jersey, as an improvement to C dialect and initially named C with classes however later it was renamed C++ in 1983. C++is a transitional dialect , as it contains an affirmation of both abnormal state and low level dialects characteristics. C++ is a statically written, free structure, multiparadigm, incorporated universally useful dialect. C++ is an Object Oriented Programming dialect yet is not absolutely protest arranged. Its peculiarities like Friend and Virtual,violate some of extremely paramount OOPS gimmicks, rendering this dialect unworthy of being called totally Object Oriented. It is a center level dialect. C++ is a standout amongst the most prevalent programming dialects and is actualized on a wide mixture of fittings and working framework stages. As an effective execution driven programming dialect it is utilized within frameworks programming, application programming, gadget drivers, inserted software,high-execution server and customer applications, and diversion programming, for example, feature amusements. Different entites give both open source and exclusive C++compiler programming, including the Microsoft and level
This paper is about the improvement of the C programming dialect, the impacts on it, and the conditions under which it was made.
It is one of the unique features of JAVA that it can omit one or
The compilers are the softwares which translates the computer language (source code) into a language more basic to the machine level. The languages such as C, C++, etc are some famous compilers. In this project, the main concept was about the understanding of compilers but the best way to explain was with the help of famous and easy Object Oriented Programming language C++.