Introduction to Computer Programming PDF
Document Details
D. Aguilar
Tags
Summary
This document provides an introduction to computer programming. It discusses programs as sets of instructions to perform tasks and software as essential components for computers. The overview covers how computers store data and basic units of memory, such as bits and bytes. Different types of programming languages are also introduced, including machine languages, assembly languages, high-level languages, and scripting languages.
Full Transcript
Prepared by D. Aguilar What is a Program? How Computers Store Data Basic Units of Memory Program is a set of instructions that a computer follows to perform a task. Programs are commonly referred to as software. Software is essential to a computer because without software, a computer c...
Prepared by D. Aguilar What is a Program? How Computers Store Data Basic Units of Memory Program is a set of instructions that a computer follows to perform a task. Programs are commonly referred to as software. Software is essential to a computer because without software, a computer can do nothing. All of the software that we use to make our computers useful is created by individuals known as programmers or software developers. A programmer, or software developer, is a person with the training and skills necessary to design, create, and test computer programs. Computer programming is an exciting and rewarding career. Today, you will find programmers working in business, medicine, government, law enforcement, agriculture, academics, entertainment, and almost every other field. All data that is stored in a computer is converted to sequences of 0s and 1s. A computer’s memory is divided into tiny storage locations known as bytes. One byte is only enough memory to store a letter of the alphabet or a small number. In order to do anything meaningful, a computer has to have lots of bytes. Most computers today have millions, or even billions, of bytes of memory. When a piece of data is stored in a byte, the computer sets the eight bits to an on/off pattern that represents the data. In computer systems, a bit that is turned off represents the number 0 and a bit that is turned on represents the number 1. The number 77 stored in a byte. The letter A stored in a byte. The smallest unit of memory is the bit. A bit can store only two different values—a zero or a one. It takes eight bits—one byte—to store a single character in memory. (A character is any symbol you can type, such as a letter, digit, or a punctuation mark.) Storing an instruction usually takes sixteen or more bits. The basic unit of memory is a byte. Memory is measured in kilobytes (KB), megabytes (MB), or gigabytes (GB). One kilobyte is 1,024 bytes One megabyte is 1,024 kilobytes. A gigabyte is 1,073,741,824 bytes. There are four fundamental types of programming languages as follows: 1. Machine languages A machine language program consists of a sequence of bits that are all zeros and ones. Machine language is the only language the computer can understand directly. 2. Assembly languages Assembly language is a symbolic representation of machine language. There is usually a one-to-one correspondence between the two; each assembly language instruction translates into one machine language instruction. This is done by a special program called an assembler. There are four fundamental types of programming languages as follows: 3. High-level languages High-level languages usually contain English words and phrases. Advantage: programs are easier to read and modify Examples: FORTRAN (FORmula TRANslator), the first high-level language, was developed in the mid- 1950s, primarily for engineering and scientific applications. C++ is currently one of the most popular languages. It is used for efficient programming of many different types of applications. COBOL (COmmon Business Oriented Language) was once the most popular language for business-related programming applications. Java is another very popular modern language, especially for web applications. Visual Basic is a new version of BASIC, an older very popular language. It is well suited for software that runs on graphical user interfaces (GUIs) There are four fundamental types of programming languages as follows: 4. Scripting languages Most scripting languages contain most of the same structures and use the same logic as the older programming languages Examples: ◦ Client-‐side (such as JavaScript) ◦ Server-‐side (such as PHP or ASP) Difference of programming and scripting: A programming language is a compiled language. When the code is run, it is translated into a machine-readable code. This process is called compilation. Compilation occurs before a program is executed. A scripting language is an interpreted language; it is not compiled. The computer, of course, still needs to have the code translated to bits and bytes for understanding. But rather than completing this process before the program is run, scripting language code is interpreted “on the fly”—that is, as each line of code is executed, it is translated by an interpreter to the computer. Today, it is more likely that a programmer will choose a language that fits the job rather than force a given language to do a job. A software developer must be fluent in several languages and understand how to quickly adapt to any new language. Therefore, it has become far more important to know the logic of writing code in any language than to focus on a specific language. Programming Logic & Design 3rd edition by Tony Gaddis Prelude to Programming Concepts and Design 6th edition by Stewart Venit and Elizabeth Drake