140 likes | 261 Views
Programming Design. Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University. Introduction. Three types of programming languages Machine languages Strings of numbers giving machine specific instructions
E N D
Programming Design Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University
Introduction Three types of programming languages • Machine languages • Strings of numbers giving machine specific instructions • Example: • +1300042774 • +1400593419 • +1200274027 • Assembly languages • English-like abbreviations representing elementary computer operations (translated via assemblers) • Example: • LOAD BASEPAY • ADD OVERPAY • STORE GROSSPAY Introduction
Introduction • High-level languages • Codes similar to everyday English • Use mathematical notations (translated via compilers) • Example: • grossPay = basePay + overTimePay Introduction
Introduction • C • A general-purpose, high-level programming language • A system programming language • Writing compilers and operating systems • Unix, Linux, Windows…. • Hardware independent (portable) • Stem from • BCPL by Martin Richards • B by Ken Thompson • Both are “typeless” language • Provide a variety of data types • characters, integers and floating numbers Introduction
Introduction • ANSI C • In 1983, the American National Standards Institute (ANSI) established a committee to provide a modern, comprehensive definition of C • Completed late in 1988 • Most of the features are supported modern compilers • ANSI/ISO C • ANSI/ISO 9899:1990 Introduction
Introduction • C++ • Superset of C developed by Bjarne Stroustrup at Bell Labs • "Spruces up" C, and provides object-oriented capabilities • Object-oriented design very powerful • 10 to 100 fold increase in productivity • Dominant language in industry and academia • Learning C++ • Because C++ includes C, some feel it is best to master C, then learn C++ Introduction
Introduction • Phases of C/C++ programs: • Edit • Preprocess • Compile • Link • Load • Execute Introduction
Preprocessor Linker Editor Disk Disk Disk Disk Disk . . . . . . . . . . . . Preprocessor program processes the code. Compiler creates object code and stores it on disk. Compiler Linker links the object code with the libraries. Primary Memory Loader Loader puts program in memory. Primary Memory CPU CPU takes each instruction and executes it, possibly storing new data values as the program executes. Introduction
MS Visual C++ • Solution (*.sln) • Consist of one or more projects (*.vcproj) • Project (*.vcproj) • Consist of many modules • Module • *.cpp/*.h • *.lib Introduction
MS Visual C++ Introduction
In C, the program to print “hello, world” is #include <stdio.h> main() { printf(“hello, world\n”); } include information about standard library define a function named main that receives no argument values Statements of main are enclosed in braces main calls library function printf to print this sequence of characters;\n represents the newline character The First C Program Introduction
Exercise 1-1 • Run the “hello, world” program on your system. Experiment with leaving out parts of the program, to see what error messages you get. Introduction
Exercise 1-2 • Experiment to find out what happens when printf’s argument string contains \c, where c is some character not listed above. • \t for tab • \b for backspace • \” for double quote • \\ for backslash Introduction