Class Note for EECS 168 at KU
Popular in Course
Popular in Department
This 13 page Class Notes was uploaded by an elite notetaker on Friday February 6, 2015. The Class Notes belongs to a course at Kansas taught by a professor in Fall. Since its upload, it has received 33 views.
Reviews for Class Note for EECS 168 at KU
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 02/06/15
Introductions to Computers amp C Programming Read Chpt 1 Do SelfTest Exercises Objective of course Studying problem solving using a computer 0 Algorithms and Data Structures Basic data structures and their associated algorithms for storing and manipulating data objects 0 Software Development The speci cation design implementation testing and documentation of software for solving speci c problems 0 Object Oriented Programming amp C Basic features of a typical object oriented programming language and the syntax semantics and use of C Computer Information processing machine Money Power Maybe Information Power De nitely Information Numeric or nonnumeric pictures sound Types of information 0 Checking account balances 0 Name and address of a potential customer 0 Picturessoundmovies 0 Computer programs and their constituent instructions 0 Others Information Storage Internal representation High level information must be encoded and stored as appropriate sequences of 0 s and 1 s Remark Computer can only understand certain sequences ofO s and 1 s Basic Unit Bit O or 1 Byte 8 bits Talking to a Computer Use a language and instructions a computer can understand Program A sequence of instructions program written in a language that a computer can understand execute Software A collection of one or more programs that performs a speci c task Application Programs Collection of software for applications Hardware Physical components of a computer Computer System Hardware Software Five Functional Units of a Computer System InputOutput Unit Handling lO Memory Unit Main vs Secondary Storing datainstructions Control Unit CU The brain coordinating all operations Arithmetic and Logical Unit ALU Executing all arithmetic and logical operations Central Processing Unit CPU CU ALU Consider the following simple task calculation Compute the area and circumference of a circle with radius 1682683 68 and print them on my screen Action Before executecompute using a computer much translation must occur Software Components Operating System Manage and allocate resources in a computer Compiler Translate a program into a language that a computer can understand Programming Languages Programming language is precise in syntax form and semantic meaning Lowlevel Machine language Sequences of 0 s amp 1 s Example 001110110010 0110 Assembly language Instructions in symbolic mnemonic form Example ADD X Y Z HighLevel Resemble human language Example Z X Y Examples of HLPL Basic Cobol Fortran C C Java Perl Q How can a computer understand a program written in a HLPL Need a translator compiler to translate it into the machine language or assembly language of the computer A compiler is also a program Integrated Development Environment IDE Editor Compiler Debugger An IDE has tightly integrated 0 Source code text editor 0 Compiler o LinkerLoader o Symbolic debugger so you don t have to decipher machine language and other binary nightmares Compiling and Executing a Program Source Program 1 Compiler 1 Object Program l Linker Executable Program l Loader V Computer ma l Output Translate HLPL t0 Machine Language 0 Source code The original program in a high level language 0 Object code The translated version in machine language A compiler is a translator whose source language is a highlevel language and whose object language is close to the machine language of an actual computer An interpreter is a program which simulates the execution of programs written in a source language An assembler is a translator whose source language an assembly language represents a onetoone transliteration of the object machine code Some compilers generate assembly code which is then assembled into machine code by an assembler A loader is a translator whose source and object languages are machine language The source language programs contain tables of data specifying points in the program which must be modi ed if the program is to be executed A linker combines the object code for the programs we write and the object code for the precompiled routines into the machine language program the CPU can run Using Computer in Problem Solving Program Algorithm Data Structures Algorithmic Problems Solving Algorithm is a sequence of stepbystep instructions that can be used to perform a speci c task Comparing Program with Algorithm Algorithm Program 1 Language independent Language dependent 2 Machine independent Usually machine dependent 3 More general Precise in form syntax 4 Always terminate May not terminate OS Program Design Process 1 Problem Formulation 2 Algorithmic Development 3 Correctness of Algorithm 4 Algorithmic Re nement 5 Implementation 6 Testing and debugging Software Life Cycle 16 7 Maintenance amp evolution of software 8 Obsolescence Correctness of Program Informal Method Testing amp Debugging Use welldesigned input data set and debugger to verify the correctness of program Will be discussed in labs Formal Method Use mathematical analysis to prove the correctness of program Will be discussed in other courses Classi cation of Program Errors Bugs 1 Design errors Solving the wrong problem 2 Logic errors Wrong assumption andor reasoning 3 Syntax errors Violating syntactic rules of language 4 Runtime errors Illegal operation during execution Example English architect designing a house for a Japanese Client English Erchitect Subcontractor 1 Translator T l Japanese Client House Subcontractor k Comparison Design a house Set of instructions Instructions The Japanese translator Translated set of instructions Japanese subcontractors Resources The house Error Examples Type Design error Logic error Syntax errors Runtime error Writing a C program syntax Your C program Tasks The C compiler Executable le from compiler Linker input data Output from your program ExampleInstance Building a wrong house Lack of building materials Violating building code Insuf cient coolinglighting 10 Introduction to C Programming C Extension of C ObjectOriented Programming Language Layout of a Simple C Program include lti0streamgt using namespace std int main variabledeclarati0ns statement 1 statementz statementn return 0 11 A Simple C Program Display 18 P 21 include lti0streamgt using namespace std int main int number0fp0ds peas per p0d total peas cout ltlt quotPress return after entering a numbernquot cout ltlt quotEnter the number of p0dsnquot cin gtgt number0fp0ds cout ltlt quotEnter the number of peas in a p0dnquot cin gtgt peas per p0d total peas number0fp0ds peas per p0d cout ltlt quotIf you have quot cout ltlt number0fp0ds cout ltlt quot pea p0dsnquot cout ltlt quotand quot cout ltlt peas per p0d cout ltlt quot peas in each pod thennquot cout ltlt quotyou have quot cout ltlt total peas cout ltlt quot peas in all the p0dsnquot return 0 12 Sample Dialogue from Example Press return after entering a number Enter the number of pods 10 Enter the number of peas in a pod 9 If you have 10 pea pods and 9 peas in each pod then you have 90 peas in all the pods 13
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'