lec2-c - ECE 175 High-level languages: Closer to human...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 175
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
High-level languages : Closer to human language, E.g. C, C++, Java, Visual Basic Easier to intuitively program Not CPU specific, portable with the right compiler Assembly languages : Closer to what the computer processes CPU specific, faster than high-level languages Tedious to program Machine language : The sequence of 0 and 1 processed by the CPU (nobody programs in this language)
Background image of page 2
05/07/09 ECE 175, Fall 2007 3 Write program in a text editor Translate program in machine code, create object files Resolve cross-references among object files and link, create executable Load executable file into memory and initiate execution File is executed and results are stored/displayed
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Write Programs – The first C Program Write a C program that prints on the screen: “Hello world” Output of the program: Hello world 05/07/09 ECE 175, Fall 2007 4 #include <stdio.h> main() { printf(“Hello World\n”}; }
Background image of page 4
Edit a program at any text editor Pico is recommended for its simplicity To launch pico write pico in a UNIX prompt You can use a freeware editor that provides language highlighting (crimson editor) Save your file with extension .c E.g. hello.c (In pico press ctrl+O) Link and compile gcc hello.c An executable file a.out is created. Execute Type a.out to execute your file (may need to type ./a.out) 05/07/09 ECE 175, Fall 2007 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Highlighting will significantly reduce the amount of errors of your code Crimson Editor is a freeware, there are others If you do so you would have to ftp your C program every time to compile ( http://sitelicense.arizona.edu/ssh/winscp_dl.php ) 05/07/09 ECE 175, Fall 2007 6
Background image of page 6
05/07/09 ECE 175, Fall 2007 7 #include <stdio.h> main() { printf(“Hello World\n”); } Instruction for the pre-processor Main Function Start of the program Statement / expression End of the program Argument Same structure regardless of the complexity of a program Pre-processor declarations Main function Begin Call of other functions (either user- created or called from libraries) End
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Writing comments in your program are very crucial for the readability of your code Common problems if you do not write comments Anyone else who reads your code cannot understand it.
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 30

lec2-c - ECE 175 High-level languages: Closer to human...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online