INTRODUCTION TO THE COURSE

Similar documents
Introduction to Computers and Visual Basic.Net Pearson Education, Inc. All rights reserved.

C++ Programming Language Lecture 1 Introduction

by Pearson Education, Inc. All Rights Reserved.

Fundamentals of Programming. Lecture 1: Introduction to C Programming

0 Introduction: Computer systems and program development

Chapter 1 Introduction to Computers and C++ Programming

Basic Computer Programming for ISNE. Santi Phithakkitnukoon ผศ.ดร.ส นต พ ท กษ ก จน ก ร

Introduction to Computers, the Internet and the Web Pearson Education, Inc. All rights reserved.

CS 241 Computer Programming. Introduction. Teacher Assistant. Hadeel Al-Ateeq

Chapter 1: An Overview of Computers and Programming Languages. Objectives. Objectives (cont d.) Introduction

Programming 1. Lecture 1 COP 3014 Fall August 28, 2017

Introduction to Computers

Spring 2018 NENG 202 Introduction to Computer Programming

Fundamentals of Programming (Python) Basic Concepts. Ali Taheri Sharif University of Technology Spring 2018

Introduction to Computers and Java. Objectives. Outline. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich.

Introduction to Computers and Java

9/11/08 (c) 2008 Matthew J. Rutherford Class (c) 2008 Matthew J. Rutherford Class

Introduction to Computers and Java

Introduction to Computers and Java. Objectives. Outline. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich.

Introduction to Computers and Java

BITG 1113: Introduction To Computers And Programming Language LECTURE 1 LECTURE 1 1

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007

Chapter 1 Overview of Programming and Problem Solving By C.K. Liang

ENERGY 211 / CME 211. Evolution

Introduction to Java Programming

EL2310 Scientific Programming

CSS331 Lecture Notes: Dr. Isaac Gang, 2011.


Programming 1 - Honors

Internet and Visual Basic Pearson Education, Inc. All rights reserved.

Chapter 1 Introduction to Computers and C++ Programming

Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer? A Bit of History

Chapter 1: Introduction

Computers in Engineering COMP 208. Computer Structure. Computer Architecture. Computer Structure Michael A. Hawker

Elements of Computers and Programming Dr. William C. Bulko. What is a Computer?

Introduction to Computers and Java

CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2003

Introduction to Programming

CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2005

Chapter. Focus of the Course. Object-Oriented Software Development. program design, implementation, and testing

Structured Languages. Rahul Deodhar

Chapter 2: Operating-System Structures

Introduction to Computers and Programming Languages. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

Object Oriented Design

Chapter 2. Basics of Program Writing

Chapter 1: Introduction to Computers and Programming

Chapter 1: Why Program? Computers and Programming. Why Program?

CS 113: Introduction to

CHAPTER 1: INTRODUCTION TO COMPUTERS AND PROGRAMMING. 1 Muhalim Mohamed Amin Faculty of

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

Introduction to Computers and Java

INFS 214: Introduction to Computing

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 1

C++ Spring Break Packet 11 The Java Programming Language

Systems Programming. The Unix/Linux Operating System

SCSP Programming Technique C

Chapter 1: Why Program? Main Hardware Component Categories 8/23/2014. Main Hardware Component Categories: Why Program?

Object Oriented Concepts and Programming (CSC244) By Dr. Tabbasum Naz

These all slide pages are selected from C How to Program, 5/e and 7/e Asst.Prof.Dr.Mahmut YALCIN

Unit 11 Computer Network Introduction to Network Operating Systems

Chapter 1. Introduction to Computers and Java Objects. Background information. » important regardless of programming language. Introduction to Java

last time in cs recitations. computer commands. today s topics.

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher

! Learn how to think like a computer scientist. ! Learn problem solving. ! Read and write code. ! Understand object oriented programming

Java and Software Design

CHAPTER 1 Introduction to Computers and Java

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

Fundamentals of Programming (C)

Computer Software. c 2016 by David W. Gerbing. School of Business Administration Portland State University

Computer Basics 1/6/16. Computer Organization. Computer systems consist of hardware and software.

Lecture 1. A. Sahu and S. V. Rao. Indian Institute of Technology Guwahati

Lesson 2: First Java Programs

Chapter 2: Operating-System Structures

MA400: Financial Mathematics

Computer Basics 1/24/13. Computer Organization. Computer systems consist of hardware and software.

CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2010

Copyright 2006 Prentice-Hall. All rights reserved. 1

Programmazione. Prof. Marco Bertini

C Compilation Model. Comp-206 : Introduction to Software Systems Lecture 9. Alexandre Denault Computer Science McGill University Fall 2006

Programming 1. Lecture 1 COP 3014 Fall August 28, 2018

Introduction. Instructor: Jia Xu CSCI-135

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

Computer Principles and Components 1

Introduction to C Programming

Chapter 2: Operating-System Structures. Chapter 2: Operating-System Structures. Objectives. Operating System Services

CS 261 Recitation 1 Compiling C on UNIX

USING CODEBLOCKS. Implementing Computational Models

Chapter 2. Editing And Compiling

General Concepts. Abstraction Computational Paradigms Implementation Application Domains Influence on Success Influences on Design

Welcome (back) to CS1007!

EL2310 Scientific Programming

Objectives. Chapter 2: Operating-System Structures. 2.1 Operating System Services

2- Computer Essentials

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

Scientific Computing

Introduction to C++ Programming. Adhi Harmoko S, M.Komp

Chapter 2: Operating-System Structures

Chapter 2 First Java Programs

Introduction to Computers, the Internet and the World Wide Web

Transcription:

1 INTRODUCTION TO THE COURSE KOM3191 Object-Oriented Programming

2 Outline Computer Organization Machine Languages, Assembly Languages and High-Level Languages History of C++ C++ Development Environment Programming Environment C++ features Running a C++ Application Using GNU C++ with Linux Object Oriented Programming

3 Objectives To learn Basic computer concepts Different level programming languages classification History of C++ The elements of C++ program development environment Some important C++ features The concept of object oriented programming Ways of setting programming environment for this course

4 Computer ~ Hardware vs. Software A computer is a device capable of performing computations and making logical decisions at speeds of millions (billions) of times faster than human beings. Hardware of a computer: Keyboard Screen Mouse Hard disk Memory etc. Computers process data under the control of sets of instructions called computer programs. The program sets that run on a computer are called software.

5 Computer Organization 1. Input units Receiving units: information is entered from input units (Keyboards, scanners, etc) 2. Output units Displaying units: takes information and places on various means (screen, printer etc.) to make it available to user. 3. Memory units Rapid access low capacity warehouse of the computer. Data here is lost when the computer is off. 4. Arithmetic and logical unit Performs calculations, responsible for decision mechanisms 5. Central processing unit Administrative section of the computer. It supervises the operation of other sections 6. Secondary storage unit Long term high capacity that stores the data not actively used by the computer (hard disks, CDs, etc.)

6 PC, distributed and Client/Server Computing 1. Apple popularized personal computing IBM introduced Personal Computers Stand alone units, data was shared using disks between computers Link computers in computer networks over phone lines & in Local area networks (LANs) 2. Distributed Computing Organization s computing is performed not only in one central computer but distributed over computer networks. 3. Today's powerful desktop machines called workstations provide individual users with enormous capabilities in client/server computing. Information is shared easily across computer networks, where computers called file servers offer a common data store that may be used by client computers distributed throughout the network. C++ has become widely used for writing software for operating systems, for computer networking and for distributed client/server applications. Today's popular operating systems such as UNIX, Linux, Mac OS X and Microsoft's Windows-based systems provide the kinds of capabilities.

7 Machine Languages, Assembly Languages and High-Level Languages Programmers write instructions in various programming languages some understood by the computers other requires intermediate translation steps. Three general programming languages: [1] 1. The lowest-level programming language machine languages are the only languages understood by computers. While easily understood by computers, machine languages are almost impossible for humans to use because they consist entirely of numbers. 2. Programmers, therefore, use either a high-level programming language or an assembly language. An assembly language contains the same instructions as a machine language, but the instructions and variables have names instead of being just numbers. 3. Programs written in high-level languages are translated into assembly language or machine language by a compiler. Assembly language programs are translated into machine language by a program called an assembler. [1] webopedia.com

8 Machine Languages, Assembly Languages and High-Level Languages Machine-language programming is simply too slow, tedious and error-prone for most programmers. Instead of using the strings of numbers that computers could directly understand, programmers began using English-like abbreviations to represent elementary operations. These abbreviations formed the basis of assembly languages. Assemblers were developed to convert early assembly-language programs to machine language at computer speeds. A high-level language focuses more on concepts that are easy to understand by the human mind, such as objects or mathematical functions. A high-level language usually is easier to understand than a machine language or assembly language, and it usually takes less time to develop a program in a high-level language.

9 Machine Languages, Assembly Languages and High-Level Languages The following is a set of instructions to add overtime pay to base pay and stores the result in gross pay Machine Language Assembly Language High-Level Language +1300042774 +1400593419 +1200274027 load basepay add overpay store grosspay grosspay = basepay + overpay;

10 High-Level Languages From the programmer's standpoint, obviously, high-level languages are preferable to machine and assembly language. C, C++, Microsoft's.NET languages (e.g., Visual Basic.NET, Visual C++.NET and C#) and Java are among the most widely used high-level programming languages.

11 Popularity of programming languages langpop.com

12 History of C++ The C++ programming language has a history going back to 1979, when Bjarne Stroustrup was doing work for his Ph.D. thesis. He had the opportunity to work with was a language called Simula. Shortly thereafter, he began work on "C with Classes", which as the name implies was meant to be a superset of the C language. His goal was to add object-oriented programming into the C language, which was and still is a language well-respected for its portability without sacrificing speed or low-level functionality. His language included classes, basic inheritance, inlining, default function arguments, and strong type checking in addition to all the features of the C language. In 1983, the name of the language was changed from C with Classes to C++. The ++ operator in the C language is an operator for incrementing a variable, which gives some insight into how Stroustrup regarded the language. In 1985, Stroustrup's reference to the language entitled The C++ Programming Language was published. That same year, C++ was implemented as a commercial product. The language was not officially standardized yet, making the book a very important reference. The language was updated again in 1989 to include protected and static members, as well as inheritance from several classes. cplusplus.com

13 History of C++ In 1990, The Annotated C++ Reference Manual was released. The same year, Borland's Turbo C++ compiler would be released as a commercial product. Turbo C++ added a plethora of additional libraries which would have a considerable impact on C++'s development. Although Turbo C++'s last stable release was in 2006, the compiler is still widely used. ANSI C++ is regular C++. The 1998 ANSI/ISO C++ standard consists of two parts: the core language and the C++ Standard Library; the latter includes most of the Standard Template Library (STL) and a slightly modified version of the C standard library. In 2003, the committee responded to multiple problems that were reported with their 1998 standard, and revised it accordingly. The changed language was dubbed C++03. In 2005, the C++ standards committee released a technical report (dubbed TR1) detailing various features they were planning to add to the latest C++ standard. In mid-2011, the new C++ standard (dubbed C++11) was finished cplusplus.com

14 C++ Development Environment C++ programs go through six phases 1. Edit 2. Preprocess 3. Compile 4. Link 5. Load 6. Execute

15 C++ Development Environment 1- Creating a source code Phase 1 consists of editing a file with an editor program (normally known simply as an editor). You type a C++ program (typically referred to as source code) using the editor, make any necessary corrections and save the program on a secondary storage device, such as your hard drive. C++ source code file names often end with the.cpp,.cxx,.cc or.c extensions (C is in uppercase) which indicate that a file contains C++ source code. 2- Preprocessing In a C++ system, a preprocessor program executes automatically before the compiler's translation phase begins. The C++ preprocessor obeys commands called preprocessor directives 3- Compiling The compiler translates C++ program into machine language code (also referred as object code). 4- Linking C++ programs typically contain references to functions and data defined elsewhere, such as in the standard libraries or in the private libraries of groups of programmers working on a particular project. A linker links the object code with the code for the missing functions to produce an executable image (with no missing pieces). If the program compiles and links correctly, an executable image is produced. 5- Loading Executable image from disk is transferred from disk to memory. Additional information from shared libraries are also loaded. 6-Execution Finally the computer executes the program one instruction at a time.

16 C++ Development Environment Compiling Linking aboutdebian.com/compile.htm

17 Programming Environment The efforts in this course will involve quite good use of Linux and GNU Compiler Collection (GCC). The basic materials to make the students familiar with GCC will be provided. You may use any platform to develop your program; your final code can be compiled and executed on Linux, as this will be the testing platform used by the instructor. 1. To compile your C++ codes, g++ (C++ compiler of GCC set) on Linux Ubuntu is a very clear way. Additions were made in order to simplify and clarify the creation of a C/C++ program on Ubuntu Linux. Working on a Linux Ubuntu operating system and provides a stand-alone programming environment with no interference. 2. For Windows users, a) Minimalist GNU for Windows (MinGW) is a development environment for Microsoft applications. MinGW includes a port of the GCC, including C, C++, ADA and FORTRAN compilers. b) With VMware Player, you can install a full copy of Linux Ubuntu and integrate it with your Windows for free. c) Integrated Development Environments (IDE's) which have complex built-in tools for editing compiling, running, and debugging programs, (Microsoft Visual Studio, Eclipse, DevCpp etc.) are not encouraged to use. While all of these will serve the purpose well, we cannot guarantee that we will be able to help you with any problems that arise in the course of using them.

18 C++ features C++...is an open ISO-standardized language. For a time, C++ had no official standard and was maintained by a de-facto standard, however since 1998, C++ is standardized by a committee of the ISO....is a compiled language. C++ compiles directly to a machine's native code, allowing it to be one of the fastest languages in the world, if optimized....is a strongly-typed unsafe language. C++ is a language that expects the programmer to know what he or she is doing, but allows for incredible amounts of control as a result....offers many multi-programming choices. C++ is designed to directly and comprehensively support multi programming styles (procedural programming, data abstraction object oriented prgramming and generic programming)...is portable. As one of the most frequently used languages in the world and as an open language, C++ has a wide range of compilers that run on many different platforms that support it. Code that exclusively uses C++'s standard library will run on many platforms with few to no changes.....is upwards compatible with C C++, being a language that directly builds off C, is compatible with almost all C code. C++ can use C libraries with few to no modifications of the C library code....has incredible library support. A search for "library" on the popular project-management website SourceForge will yield over 3000 results for C++ libraries. A link to the results of the search may be found here.

19 Running a C++ Application Using GNU C++ with Linux For this test drive, we assume that you know how to copy the examples into your home directory. The prompt in the shell on our system uses the tilde (~) character to represent the home directory and each prompt ends with the dollar sign ($) character. The prompt will vary among Linux systems. 1. Locate your application 2. Compile and link your codes 3. Run your application file ----- {on the Linux shell} mm@ubuntu:~$ mm@ubuntu:~$ cd kom3191 mm@ubuntu:~$ indicates the use off shell on a the account of mm@ubuntu -o file (rename output file, default is a.out in UNIX/Linux -Wall (Display all warnings) g++ is the C++ compiler of the GCC set test_guessnumber is the application file./ means an application file is invoked mm@ubuntu:~/kom3191$ g++ -Wall -o test_guessnumber guessnumber.cpp mm@ubuntu:~/kom3191$./test_guessnumber I have a number between 1 and 1000. Can you guess my number? Please type your first guess.

20 Object-oriented programming Object-oriented design (OOD) models software in terms similar to those that people use to describe real-world objects. Such as a class of vehicles, have the same characteristics cars, trucks, little red wagons and roller skates have much in common. OOD takes advantage of inheritance relationships, where new classes of objects are derived by absorbing characteristics of existing classes and adding unique characteristics of their own. Object-oriented design provides a natural and intuitive way to view the software design process namely, modeling objects by their attributes, behaviors and interrelationships just as we describe real-world objects. OOD also models communication between objects. Just as people send messages to one another (e.g., a sergeant commands a soldier to stand at attention), objects also communicate via messages. A bank account object may receive a message to decrease its balance by a certain amount because the customer has withdrawn that amount of money. OOD encapsulates (i.e., wraps) attributes and operations (behaviors) into objects an object's attributes and operations are intimately tied together. Objects have the property of information hiding. Programming in such a language is called object-oriented programming (OOP), and it allows computer programmers to implement an object-oriented design as a working software system. Languages like C, on the other hand, are procedural, so programming tends to be action oriented. In C, the unit of programming is the function. In C++, the unit of programming is the class