Presentation is loading. Please wait.

Presentation is loading. Please wait.

 Getting ready to code Lecture 1 Match 4, 2013. Course syllabus 

Similar presentations


Presentation on theme: " Getting ready to code Lecture 1 Match 4, 2013. Course syllabus "— Presentation transcript:

1  Getting ready to code Lecture 1 Match 4, 2013

2 Course syllabus  http://synteam.org/language/ http://synteam.org/language/

3 Why study programming?  http://www.youtube.com/watch?v=tVtvCAYBhTg http://www.youtube.com/watch?v=tVtvCAYBhTg  Autonomous vehicle project  http://www.youtube.com/watch?v=kMn4_AyMAjE http://www.youtube.com/watch?v=kMn4_AyMAjE  http://www.youtube.com/watch?v=8d-zrsy_zfk http://www.youtube.com/watch?v=8d-zrsy_zfk  http://www.youtube.com/watch?v=bp9KBrH8H04 http://www.youtube.com/watch?v=bp9KBrH8H04  Brain analysis through eye blink detection  http://www.youtube.com/watch?v=_5UHCNevrPM http://www.youtube.com/watch?v=_5UHCNevrPM  http://www.youtube.com/watch?v=EVgXeTGhARc http://www.youtube.com/watch?v=EVgXeTGhARc  Mobile robot control  http://www.youtube.com/watch?v=iLUl81e6OSs http://www.youtube.com/watch?v=iLUl81e6OSs

4 Example Face and eyes detection program

5 Continuation

6 Demonstration  Face recognition program

7 What is Programming?  Programming is instructing a computer to do something for you with the help of a programming language  The two roles of a programming language:  Technical: It instructs the computer to perform tasks.  Conceptual: It is a framework within which we organize our ideas about things and processes.  In programming, we deal with two kind of things:  Data - representing 'objects' we want to manipulate  Procedures -'descriptions' or 'rules' that define how to manipulate data. 7

8 Programming Language  Formal Language used to communicate to a computer.  A programming language contains instructions for the computer to perform a specific action or a specific task:  'Calculate the sum of the numbers from 1 to 10‘  'Print “I like programming”‘  'Output the current time' 8

9 Programming Language  Can be classified into as a  special-purpose and  general-purpose programming languages.  Special-purpose : is design for a particular type of application  Structured Query Language (SQL)  General-purpose : can be used to obtain solutions for many types of problems 1. Machine Languages 2. Assembly Languages 3. High-Level Languages 9

10 Machine Language  The only language that the processor actually 'understands‘  Consists of binary codes: 0 and 1  Example: 00010101 11010001 01001100  Each of the lines above corresponds to a specific task to be done by the processor. 10

11 Machine Language Programming in machine code is difficult and slow since it is difficult to memorize all the instructions. Mistakes can happen very easily. Processor and Architecture dependent Simple add numbers program 1.Copy the number in memory location 2000 to register 1. 2.Copy the number in memory location 2004 to register 2. 3.Add the contents of register 2 to the contents of register 1, leaving the answer in register 1. 4.Copy the contents of register 1 to memory location 2008. Register is a small amount of storage available as part of a CPU. Machine language Machine instructions are written in hexadecimal system

12 Assembly Language  Enables machine code to be represented in words and numbers.  Example of a program in assembler language:  Easier to understand and memorize (called Mnemonics), compared to machine code but still quite difficult to use.  Processor and Architecture dependent 12 LOAD A, 9999 LOAD B, 8282 ADD B MOV C, A LOAD C, #0002 DIV A, C STORE A, 7002

13 High-level Computer Languages  Use more English words. They try to resemble English sentences. Therefore, it is easier to program in these languages.  The programming structure is problem oriented - does not need to know how the computer actually executes the instructions.  Processor independent - the same code can be run on different processors.  Examples: Basic, Fortran, Pascal, Cobol, C, C++, Java  A high level language needs to be analyzed by the compiler and then compiled into machine code so that it can be executed by the processor. 13

14 High-level Computer Languages  High-level computer languages simplify our programming life in several ways. First, you don't have to express your instructions in a numeric code.  To add two numbers, for example, you might write the following: total = mine + yours; The compiler is a program that translates the high-level language program into the detailed set of machine language instructions the computer requires.

15 Why C? Design Features – Efficiency (C programs tend to be compact and to run quickly.) – Portability (C programs written on one system can be run on other systems with little or no modification.) – Power and Flexibility (OS and programing languages are written in C.) – Programmer Oriented (It gives you access to hardware, and it enables you to manipulate individual bits in memory) – Shortcomings ( you can make programming errors that are very difficult to trace )

16 Why C?  If you want a job writing software, one of the first questions you should be able to answer yes to is "Oh say, can you C?”  C languages programs are always in demand. http://jobs.phds.org/job/36517/asset-management- company/senior-quantitative-programmer-c- c?utm_source=Indeed&utm_medium=organic&utm_campaign =Indeed

17 Where C is applied?

18 History of C Language Why it is named 'C' ?  Because based on ' B '; developed at B ell Laboratories  Developed by Dennis Ritchie at Bell Laboratories in the 1960s  In cooperation with Ken Thomson it was used for Unix systems  The C Language was only vaguely defined, not standardized, so that almost everyone had his own perception of it, to such an extend that an urgent need for a standard code was creeping up  In 1983, the American National Standards Institute (ANSI) set up X3J11, a Technical Committee to draft a proposal for the ANSI standard, which was approved in 1989 and referred to as the ANSI/ISO 9899 : 1990 or simply the ANSI C, which is now the global standard for C. 18

19 19 History of C Language

20 C – An Imperative Language #include int main(void) { printf(”Hello world.\n"); return 0; } 20  C is a highly imperative language  We must tell it exactly how to do what;  the means and functions to use;  which libraries to use;  when to add a new line;  when an instruction is finished;  in short: everything and anything… A simple program

21 Programming Mechanics  When you write a program in the C language, you store what you write in a text file called a source code file.  Most C systems (MS Windows, Linux, Mac, ) require that the name of the file end in.c (for example, wordcount.c and budget.c). The hello.c Program #include int main(void) { printf(”Hello world.\n"); return 0; } st an d ard Library, i nput- o utput, h eader-file Begin of program Function for printing text End of statement Insert a new line End of Segment 21

22 Overview of a C program 22

23 Object Code Files, Executable Files, and Libraries 1.The compiler converts your source code to an intermediate code (object code file), and the linker combines this with other code to produce the executable file. 2.The object file contains machine language code, it is not ready to run; 3.The first element missing from the object code file is something called startup code; 4.The second missing element is the code for library routines 5.The role of the linker is to bring together these three elements—your object code, the standard startup code for your system, and the library code—and put them together into a single file, the executable file. 23

24 Process of compiling and running a C program 24

25 Using C: Seven Steps 1. Define the program objectives; 2. Design the program; 3. Write the code; 4. Compile; 5. Run the program; 6. Test and debug the program; 7. Maintain and modify the program. 25

26 Define the program objectives  Start with a clear idea of what you want the program to do;  Think in terms of the information your program needs;  And the information the program should report back to you;  Think in general terms, not in terms of some specific computer language. 26

27 Design the program  What should the user interface be like?  How should the program be organized?  Who will the target user be?  How much time do you have to complete the program?  Think in general terms, not about specific code. 27

28 Write the Code Now that you have a clear design for your program, you can begin to implement it by writing the code. #include int main(void) { int dogs; printf("How many dogs do you have?\n"); scanf("%d", &dogs); printf("So you have %d dog(s)!\n", dogs); return 0; } 28

29 Compile  The compiler is a program whose job is to convert source code into executable code ;  Executable code is code in the native language, or machine language, of your computer;  C compilers also incorporate code from C libraries into the final program; the libraries contain a fund of standard routines, such as printf() and scanf(), for your use. (More accurately, a program called a linker) 29

30 Run the Program  The executable file is a program you can run. 30

31 Test and Debug the Program  The fact that your program runs is a good sign, but it's possible that it could run incorrectly;  Some of your programs have mistakes—bugs;  Debugging is the process of finding and fixing program errors;  The compiler catches many kinds of errors, and there are things you can do to help yourself track down the ones that the compiler doesn't catch. 31

32 Maintain and modify the program  You could add a clever new feature.  You might adapt the program so that it runs on a different computer system.  All these tasks are greatly simplified if you document the program clearly and if you follow sound design practices. 32

33 Questions?


Download ppt " Getting ready to code Lecture 1 Match 4, 2013. Course syllabus "

Similar presentations


Ads by Google