Introduction to Computer Programming
Total Page:16
File Type:pdf, Size:1020Kb
Introduction to Computer Programming CISC1600/1610 Computer Science I/Lab Spring 2016 CISC1600 Yanjun Li 1 Outline This Course Computer Programming Spring 2016 CISC1600 Yanjun Li 2 1 This is a course In Programming For beginners who want to become professionals or who would like to know something about programming who are assumed to be bright Though not (necessarily) geniuses who are willing to work hard Though do need sleep occasionally, and take a normal course load Using the C++ programming language Spring 2016 CISC1600 Yanjun Li 3 Learning Goals Learn Fundamental programming concepts Key useful techniques Basic Standard C++ facilities After the course, you’ll be able to Write small sound C++ programs Read much larger programs Learn the basics of many other languages by yourself Proceed with an “advanced” C++ programming course After the course, you will not (yet) be An expert programmer A C++ language expert An expert user of advanced libraries Spring 2016 CISC1600 Yanjun Li 4 2 The Means Lectures Attend every one Outside of lectures Read a chapter ahead, and read the chapter again after each lecture Read actively: with questions in mind, try to reorganize/rephrase the key points in your mind Review questions/Terms in chapters Drills Always do the drills, before the exercises Exercises Spring 2016 CISC1600 Yanjun Li 5 The Means (Cont.) Lab projects That’s where the most fun and the best learning takes place Don’t wait until lab section to start the project Start to think about the project early Finish up & get help during labs Exams Midterms Final Spring 2016 CISC1600 Yanjun Li 6 3 How to be Successful? Don’t study alone when you don’t have to Form study groups Do help each other (without plagiarizing) If in doubt if a collaboration is legitimate: ask! Don’t claim to have written code that you copied from others Don’t give anyone else your code (to hand in for a grade) When you rely on the work of others, explicitly list all of your sources – i.e. give credit to those who did the work Seek help: tutor’s room, my office hours Go prepared with questions The only stupid questions are the ones you wanted to ask but didn’t Spring 2016 CISC1600 Yanjun Li 7 Outline This Course Computer Programming Spring 2016 CISC1600 Yanjun Li 8 4 What is Computer System ? Computer System is a system capable of Performing computations Making logical decisions Works billions of times faster than human beings Components of a computer system: Hardware Software Spring 2016 CISC1600 Yanjun Li 9 Hardware The hardware components are the electronic and mechanical parts. hardware devices Keyboard, mouse, etc. Screen (monitor) Disks Memory Processing Units Spring 2016 CISC1600 Yanjun Li 10 5 Major Hardware Components Input devices Obtains data from outside of the computer. Usually a keyboard, mouse, disk or scanner Output devices Makes info available outside the computer. Screens, paper printouts, speakers Spring 2016 CISC1600 Yanjun Li 11 Major Hardware Components Processor Central Processing Unit or CPU The brain of a computer system. It does the fundamental computing within the system. Responds to and processes the basic instructions that drive a computer. Directly or indirectly controls all the other components. Spring 2016 CISC1600 Yanjun Li 12 6 Major Hardware Components Memory holds data and programs that CPU is using, and save results of programs. Rapid access, low capacity (relative), short-term, temporary “warehouse”. Often called main memory, primary memory, or Random Access Memory (RAM) “4 gigabytes (4GB) of RAM” One megabyte of memory is enough to hold approximately one million characters of a word processing document. 0/1 – one bit, 8 bits = 1 byte, 210 =1024 bytes = 1 kilobyte, 10242 bytes = 1 megabyte, 10243 bytes = 1 gigabyte Spring 2016 CISC1600 Yanjun Li 13 Major Hardware Components Secondary storage Stores programs or data not currently being used by other units on secondary storage devices (like hard disk and flash drive) Long-term, high-capacity “warehouse” Takes longer to access than primary memory Spring 2016 CISC1600 Yanjun Li 14 7 Questions Imagine that you are using a word processor program to write a letter. Where (in the computer system) is the program you are running? Where are the characters you have typed before you hit “save” button? After you hit “save” button? Spring 2016 CISC1600 Yanjun Li 15 Answers Where (in the computer system) is the program you are running? In main memory. (A permanent copy will also be in secondary storage--the hard disk). Where are the characters you have typed? In main memory. (When you "save" your document, they will be copied to a file on the hard disk or the place you specified.) Spring 2016 CISC1600 Yanjun Li 16 8 Outline This Course Computer Programming Spring 2016 CISC1600 Yanjun Li 17 What is Computer Program ? Programming is communicating between programmer and computer. Computer Programs are called software sets of instructions that process data guide computer through orderly sets of actions specified by computer programmers Programmers write instructions that comprise software in various programming languages Spring 2016 CISC1600 Yanjun Li 18 9 Types of Programs Two categories of programs. Application programs are programs that people use to get their work done. Word Processor, Web Browsers, etc. System programs keep all the hardware and software running together smoothly. Operating System is a kind of software system which is developed to make using computers more convenient. Windows, Unix, Linux, Macintosh. The difference between "application program" and "system program" is fuzzy. Spring 2016 CISC1600 Yanjun Li 19 Types of Programming Languages Three general types of programming languages Machine languages machine dependent Assembly languages machine dependent High-level languages most are portable Specific languages include C, C++, Visual Basic and Java Spring 2016 CISC1600 Yanjun Li 20 10 History of C and C++ C evolved from two previous programming languages, BCPL and B. They were used to develop operating- systems software C initially became widely known as the development language of the UNIX operating system. C is now available for most computers and is hardware independent. A standard version of C is available. Spring 2016 CISC1600 Yanjun Li 21 History of C and C++ C++, an extension of C, was developed in the early 1980s. C++ provides a number of features that "spruce up" the C language, but more importantly, it provides capabilities for object- oriented programming. Objects are essentially reusable software components that model items in the real world. A modular, object-oriented design and implementation approach is more productive. Object-oriented programs are easier to understand, correct and modify. Spring 2016 CISC1600 Yanjun Li 22 11 C++ Standard Library C++ programs consist of pieces called classes and functions C++ Standard Library : Rich collections of existing classes and functions Reusable in new applications Two parts to learning the C++ "world." Learning the C++ language itself; Learning how to use the classes and functions in the C++ Standard Library. Spring 2016 CISC1600 Yanjun Li 23 Reference Reproduced from the Cyber Classroom for C++, How to Program, 5/e by Deitel & Deitel. Reproduced by permission of Pearson Education, Inc. Spring 2016 CISC1600 Yanjun Li 24 12.