Send
Close Add comments:
(status displays here)
Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
C: Intro and edit-compile-run
1. C: Intro and edit-compile-run
2. Input-process-output model
3. Computer
4. Computer
A
computer is a machine that performs computations.
5. Resources
6. Resources
The resources of the computer include keyboard, mouse, screen, printer, etc.

Some
resources of the computer are the following.
input from the keyboard, mouse, etc.
output to the screen, printer, etc.
storage to/from disk drives, etc.
processing by the CPU (Central Processing Unit) .
7. Simplification
To simplify things, in many cases these ideas will be abstracted to the following.
Input comes from the keyboard or a text file.
Output goes to the screen or a text file.
For testing (except some user interfaces) the simplification goes further.
Input comes from a (usually text) file.
Output goes to a (usually text) file.
8. Programming languages
9. Programming languages
A
programming language is a notation for describing a computation.
10. Compilers
A programming language is a readable form for describing a computation that needs to be translated, usually via a
compiler, to a pretty much unreadable machine code format that the computer understands.
program text is legible (readable by humans, perhaps not easily )
binary code is illegible (not legible, not readable by most humans)
11. Programmer
12. Programmer
A programmer is a person who takes requirements and implements a computer program that meets those requirements.
Programming a computer is like learning a foreign language.
You can get started in a few minutes, but after a lifetime there will still be things to learn.
To call yourself a "real" programmer, you should have written at least one program that someone else uses on a regular basis to do something useful.
13. Programming
Some programmers create "new" code from scratch.
Some programmers maintain "old" code.
Programmers writing "new" code glue together pieces of existing code using a
SDK (
Software Development Kit) , software library, etc., to do new things.
Many programmers learn and use only one programming language and many programmers only work with and support one program or software system.
14. Edit-compile-run cycle
15. General problem solving
16. General problem solving process

1. You, your teacher, your boss, etc., may identify the problem.
2. Then a lot of definition needs to be researched, decided.
3. A solution needs to be designed for effectiveness and efficiency.
4. The solution needs to be implemented.
5. The implemented solution is evaluated/tested.
At any point in the process one may need to go back to a previous step.
This process is done recursively on smaller parts of the overall problem.
17. Specific problem solving

Here is a specific problem solving method for program development.
Step 0. Determine the program requirements.
Step 1. Create/modify the program text.
Step 2. Compile the program. If any compile-time errors are detected, return to step 1.
Step 3. Run the program. If any run-time errors are detected, return to step 1.
Step 4. Test the program. If the program does not meet the program requirements, return to step 1.
Obviously, returning to the beginning (i.e., step 1) can slow down the program implementation and development process.
This process is called the edit-compile-run cycle.
18. Edit-compile-run in more detail
We now cover each step of the edit-compile-run cycle in more detail using the C programming language. But first, we need to cover some terminology.
A computer program is a specification of a computation.
A computer program is sometimes called the source text. A program in text form is easy for human programmers to work with and understand.
19. Dijkstra: Computations
A program is never a goal in itself. The purpose of a program is to evoke computations and the purpose of the computations is to establish a desired effect. 1972.
Edsger Dijkstra (computations) Dahl, O., Dijkstra, E., & Hoare, C. (1972).
Structured programming. New York: Academic Press.. .
20. Programming languages
A
programming language is a notation for specifying a computation.
Some common computer programming languages include the following.
C/C++
Java
Python
Web languages: ASP, PHP, Perl, Python, Ruby, etc.
In this course, we will use the programming language C.
21. Requirements specification
Before you can create a program, you need to determine the requirements for the program, determine a set of specifications, and plan and create a design for the program.
For a beginning programming course, you are usually given the requirements, the specifications, and a way in which to design the program that you are to create.
Your job, then, is to write a program that accomplishes the requirements according to the specifications. In later courses, you may be required to do the requirements and/or specifications in addition to the implementation.
22. First program
When learning a new programming language or system, the first program you attempt should be very simple.
Our first program will be a program that has no input and outputs text to the standard output stream, which is usually the screen.
The first program is often called the "Hello, World" program. This program has no input and outputs the text "Hello, World" to the standard output, usually the screen.
23. Program text
Here is the text for a C program that outputs the text "
Hello, World".
to be added
For now, we will not concern ourselves with the structure of the program, how it works, why it works, etc.
We will only be concerned with the mechanics of the three steps of the edit-compile-run cycle.
1. Create/modify the program text, also called source code.
2. Compile the program text to binary code, also called object code.
3. Run the binary code to take input, if any, and create output.
24. Step 1. Create/modify the program
The first step is to create and/or modify a program to meet the requirements using a text editor. This is called editing a program.
In Windows, the Notepad++ text editor is popular.
In Linux, a popular command line editor is nano.
There are many other very good text editors.
Any changes made must be saved before going to the next step. Most programming systems have editors that "know" something about the program as text. Notepad knows nothing about your program.
25. Compile the program
An executable program containing machine instructions in binary form, called binary code, that is needed in order to have a microprocessor (or another program) execute the program (i.e., execute the instructions).
A compiler translates a source program in text form into an object program that contains machine instructions..
The object program is sometimes called the target code.
26. Programming language levels
The programming process is built an layered abstractions.
high level programming language
low level assembly language
machine language in hexadecimal
machine code in binary
microprocessor execution
27. Programming language
Here is a BASIC programming statement to output the character "A".
Print "A" ' output the character "A"
The statement needs to be translated, or compiled, to assembly language code. Here, 8086 assembly language code will be used.
28. CPU registers
29. Low level assembly language
MOV DX,41h ; move character "A" = 65d = 41h to register DX
MOV AH,2 ; move 2 to register AH
INT 21h ; call DOS API at software interrupt location 21h
The assembly language code then needs to be translated, or assembled, into machine language.
30. Machine language in hexadecimal
In hexadecimal, the machine language code has a very close visual relationship with the assembly language instructions.
BA4100 ; "MOV DX" is BAh , "41h" == "4100" (16 bits)
B402 ; "MOV AH" is B4h , "02h" == "02" ( 8 bits)
CD21 ; "INT" is CDh , "21h" == "21" ( 8 bits) DOS API
31. Machine code in binary
In binary, the machine language code is in a form that the microprocessor can recognize and execute.
10111010 01000001 00000000 ; BA 41 00
10110100 00000010 ; B4 02
11001101 00100001 ; CD 21
32. Microprocessor execution
The microprocessor can execute the binary machine code when it has been converted to high (1) and low (0) voltage levels.
33. Link the program
Most programs consist of many different parts and modules. In order to create an executable program, these different parts must be combined together to form an executable file.
34. Linker
A
linker is a program that combines object programs containing machine instructions into a single executable program file that can be run.
35. Executable programs
An executable program is a program that can be run.
The default file extensions for most Windows executable files that contain binary machine instructions are
.exe or
.dll.
A
.dll program is a
DLL (
Dynamic Link Library) program that, in Windows, contains executable binary machine instructions that are shared by other programs.
For example, the Windows operating system consists of a large number of
.dll programs.
36. Java execution model
The Java execution model features a
JIT (
Just In Time) compiler that verifies the compiled Java byte-code (i.e., byte-string) before running the code.
This allows Java to run on many computers with some level of security (especially for Internet-based applications).
37. Integrated development environments
The edit-compile-run process/cycle can get very repetitive and tedious.
An
IDE (
Integrated Development Environment) contains a convenient user-friendly visual interface for accomplishing the edit-compile-run cycle as well as providing features for debugging programs, etc.
command line and text editor
Visual Studio (.NET, etc.)
Eclipse
Emacs
Many graphical editors provide some form of development environment.
38. End of page
39. Multiple choice questions for this page
31 questions omitted (login required)
40. Acronyms and/or initialisms for this page
5 acronyms omitted (login required)