30
COM 235 Engineering Computer Programming I (3 Credits) Lecture 1 Warming Up Dr. Eng. Essam Abdrabou

lecture01.ppt

Embed Size (px)

Citation preview

  • COM 235Engineering Computer Programming I(3 Credits)

    Lecture 1Warming UpDr. Eng. Essam Abdrabou

  • Course PrerequisitesPrerequisites:No prior programming experience requiredWho should be taking this course

  • Course DescriptionThis course is designed to provide students with an in depth coverage of the basics of programming in C++, which is needed for application development. It is planned to make the students well acquainted with the syntax and semantics of the C++ programming language.This is done through teaching the Input/output instructions, the different data type used in the language, the different arithmetic operations, control structures, arrays, and functions.

  • What the class is really aboutThere are two main goals of this course:Basics of C++We will learn how to program in C.We will cover all the fundamentals: Variables, For Loops, While Loops, Arrays, Functions.Core Concepts of Programming LanguagesThere are lots of programming languages available: Pascal, Java, C#, Fortran.All of these languages share core concepts.By focusing on these concepts, you are better able to learn any programming language.

  • Administrative IssuesCourse web site is available at: Book:Programming in C++, McGraw Hill, 2009.Software

  • GradingYour grade will be determined as follows:One Midterm (20%)One Final Exam (40%)Course Work (40%)Quizzes, Attendance, Participation, Homework (15%)Practical Exam. (15%)Labs. (10%)

  • A Word About CheatingCheating is defined as: Copying all or part of others homework, project or exam. Others include your colleagues and/ or the cyberspaceAllowing another student to copy all or part of your homework, project, or exam. Discussing homework concepts is fine, but you must submit your own work.If you are caught cheatingyou will receive an immediate FAILURE for the course.

  • DisciplinePlease be on time to class!Please do not talk to your friends and neighbors in class! It disturbs everyone, and makes it hard to concentrate. If you have a question, just ask me!Please turn your cell-phones off!

  • The Lego TheoryThe Lego Theory: Complex softwareis built with simple, basic building blocks.

  • Lego Theory Applied: Basic ExampleLego Block: For loop for repeating actions. Suppose you want to print your name five times.Lego Block: std::coutfor displaying yournameMain Lego Block: For Coordinating everything

  • How we will use the Lego TheoryEach week, we will introduce a new basic building block.By combining these blocks, we can start creating more and more powerful programs.By the end of the semester, you will have all the basic blocks for building a sophisticated software.

  • SyllabusWeek 1: MissedWeek 2: This IntroductionWeek 3: Variables, Basic MathematicsWeek 4: Decision (If/Else)Week 5-6: Iterations (Loops)Week 7-8: Mid TermWeek 9-12: ArraysWeek 13-14: FunctionsWeek 15: Final

  • What is a Computer?Computer Device capable of performing computations and making logical decisionsComputers process data under the control of sets of instructions called computer programs Hardware Various devices comprising a computerKeyboard, screen, mouse, disks, memory, CD-ROM, and processing unitsSoftware Programs that run on a computer

  • Computer OrganizationSix logical units in every computer:Input unitObtains information from input devices (keyboard, mouse)Output unit Outputs information (to screen, to printer, to control other devices)Memory unit Rapid access, low capacity, stores input informationArithmetic and logic unit (ALU) Performs arithmetic calculations and logic decisionsCentral processing unit (CPU) Supervises and coordinates the other sections of the computerSecondary storage unit Cheap, long-term, high-capacity storageStores inactive programs

  • Evolution of Operating SystemsBatch processingDo only one job or task at a timeOperating systems Manage transitions between jobsIncreased throughputAmount of work computers processMultiprogramming Computer resources are shared by many jobs or tasksTimesharingComputer runs a small portion of one users job then moves on to service the next user

  • Personal Computing, Distributed Computing, and Client/Server ComputingPersonal computers Economical enough for individualDistributed computing Computing distributed over networksClient/server computingSharing of information across computer networks between file servers and clients (personal computers)

  • Machine Languages, Assembly Languages, and High-level LanguagesThree types of programming languagesMachine languages Strings of numbers giving machine specific instructionsExample:+1300042774+1400593419+1200274027Assembly languagesEnglish-like abbreviations representing elementary computer operations (translated via assemblers)Example:LOAD BASEPAYADD OVERPAYSTORE GROSSPAY

  • Machine Languages, Assembly Languages, and High-level LanguagesHigh-level languagesCodes similar to everyday EnglishUse mathematical notations (translated via compilers)Example:grossPay = basePay + overTimePay

  • History of C and C++History of CEvolved from two other programming languagesBCPL and BTypeless languagesDennis Ritchie (Bell Laboratories)Added data typing, other featuresDevelopment language of UNIXHardware independentPortable programs1989: ANSI standard1990: ANSI and ISO standard publishedANSI/ISO 9899: 1990*

  • History of C and C++History of C++ Extension of CEarly 1980s: Bjarne Stroustrup (Bell Laboratories)Provides capabilities for object-oriented programmingObjects: reusable software components Model items in real worldObject-oriented programsEasy to understand, correct and modifyHybrid languageC-like styleObject-oriented styleBoth*

  • C++ Standard LibraryC++ programsBuilt from pieces called classes and functionsC++ standard libraryRich collections of existing classes and functionsBuilding block approach to creating programsSoftware reuse*

  • Structured ProgrammingStructured programming Disciplined approach to writing programsClear, easy to test and debug and easy to modifyMain focus of this course.

  • Basics of a Typical C++ Program Development EnvironmentPhases of C++ Programs:EditPreprocessCompileLinkLoadExecute

  • *A Simple Program:Printing a Line of TextCommentsDocument programsImprove program readabilityIgnored by compilerSingle-line commentBegin with //Preprocessor directivesProcessed by preprocessor before compilingBegin with #

  • *

  • *A Simple Program:Printing a Line of TextStandard output stream objectstd::coutConnected to screen
  • A Simple Program:Printing a Line of Text*

    Escape Sequence

    Description

    \n

    Newline. Position the screen cursor to the beginning of the next line.

    \t

    Horizontal tab. Move the screen cursor to the next tab stop.

    \r

    Carriage return. Position the screen cursor to the beginning of the current line; do not advance to the next line.

    \a

    Alert. Sound the system bell.

    \\

    Backslash. Used to print a backslash character.

    \"

    Double quote. Used to print a double quote character.

  • *

  • Homework #1Write the following program and check how it is working.*

  • *

    ******************************