Topic 1: Programming concepts

Similar documents
Topic 2: C++ Programming fundamentals

Topic 10: Introduction to OO analysis and design

(0) introduction to the course. how to learn a programming language. (0) course structure

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

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

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

Programming 1 - Honors

EP241 Computer Programming

C++ Programming for Non-C Programmers. Supplement

CSc 10200! Introduction to Computing. Lecture 1 Edgardo Molina Fall 2013 City College of New York

Chapter 1 INTRODUCTION

printf( Please enter another number: ); scanf( %d, &num2);

UEE1302 (1102) F10: Introduction to Computers and Programming

Fundamentals of Programming. By Budditha Hettige

Lab # 02. Basic Elements of C++ _ Part1

EKT 120/4 Computer Programming KOLEJ UNIVERSITI KEJURUTERAAN UTARA MALAYSIA

Your First C++ Program. September 1, 2010

IS12 - Introduction to Programming. Lecture 7: Introduction to C

Understanding main() function Input/Output Streams

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

Introduction to Computing using C++ Biomedical applications WELCOME TO CIS 1.5. Introduction to the course. Course structure

Identifiers. Identifiers are the words a programmer uses in a program Some identifiers are already defined. Some are made up by the programmer:

C++ Support Classes (Data and Variables)

Chapter 2 Basic Elements of C++

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

INFS 214: Introduction to Computing

Lesson 1. Introduction to Programming OBJECTIVES

Low-Level Languages. Computer Programs and Programming Languages

ENT 189: COMPUTER PROGRAMMING. H/P: Home page:

Chapter 1: Introduction to Computers and Programming

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

Introduction to Java Programming

Scientific Computing

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

6.096 Introduction to C++ January (IAP) 2009

CE221 Programming in C++ Part 1 Introduction

Unit. Programming Fundamentals. School of Science and Technology INTRODUCTION

4. Structure of a C++ program

C++ Programming: From Problem Analysis to Program Design, Third Edition

Introduction to Programming using C++

1) What is the first step of the system development life cycle (SDLC)? A) Design B) Analysis C) Problem and Opportunity Identification D) Development

ENGINEERING PROGRAMMING

C PROGRAMMING THE C PROGRAMMING THE PDF C PROGRAMMING TUTORIAL IN PDF - CURRENT AFFAIRS 2018 C (PROGRAMMING LANGUAGE) - WIKIPEDIA

Problem Solving and Program Design - Chapter 1. Cory L. Strope

Lab 1: Introduction to C Programming. (Creating a program using the Microsoft developer Studio, Compiling and Linking)

During the first 2 weeks of class, all students in the course will take an in-lab programming exam. This is the Exam in Programming Proficiency.

CS103 Lecture 1 Slides. Introduction Mark Redekopp

CS313T ADVANCED PROGRAMMING LANGUAGE

CSC180: Lecture 2. Wael Aboulsaadat.

Curriculum Map Grade(s): Subject: AP Computer Science

Lesson 01 Introduction

Introduction. Arizona State University 1

C++ for Python Programmers

Instructor. Mehmet Zeki COSKUN Assistant Professor at the Geodesy & Photogrammetry, Civil Eng. (212)

8/16/12. Computer Organization. Architecture. Computer Organization. Computer Basics

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

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

ENGR/CS 101 CS Session Lecture 3

Procedural Programming

1 The Catholic University of Eastern Africa P.o Box , Nairobi Kenya Edward Kioko 2013

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.1

CS 132 Exam #1 - Study Suggestions

CMPT-101. CMPT-101-D2, Spring Course Web Page Course Mailing List. Exams. Assignments

Module 1: Introduction to Computers, Programs, and Java

Object Oriented Design

Welcome. Orientation to online CPS102 Computer Science 2 (Java 2)

Engineering Computing M1H Together Towards A Green Environment

Module specification

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

Computer Science II Lecture 1 Introduction and Background

Week 2: Data and Output

Chapter 1: A First Program Using C#

Chapter 9. Introduction to High-Level Language Programming. INVITATION TO Computer Science

Introduction to Programming

Programming: detailed instructions which tell the computer hardware what to do aka software Computer Science: the study NOT of computers, but of what

CS31 Discussion 1E. Jie(Jay) Wang Week1 Sept. 30

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

CS1500 Algorithms and Data Structures for Engineering, FALL Virgil Pavlu, Jose Annunziato,

Full file at

Tutorial-2a: First steps with C++ programming

Introduction. Instructor: Jia Xu CSCI-135

Compilers for Modern Architectures Course Syllabus, Spring 2015

Unit 1 : Principles of object oriented programming

Lecture 1: Preliminaries

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

Introduction to Basis and Practice in Programming

Job Ready Assessment Blueprint. Computer Programming. Test Code: 4023 / Version: 01

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

DEPARTMENT OF COMPUTER AND MATHEMATICAL SCIENCES UNIVERSITI TEKNOLOGI MARA CAWANGAN PULAU PINANG

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

Lab 1: First Steps in C++ - Eclipse

Intro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Why Learn to Program?

Chapter - 2 The Basics of Programming. Practical C++ Programming Copyright 2003 O'Reilly and Associates Page1

Embedded Systems. 2. Software Development. Lothar Thiele. Computer Engineering and Networks Laboratory

Programming for Problem Solving 105A L T P Credit Major Minor Total Time

The births of the generations are as follow. First generation, 1945 machine language Second generation, mid 1950s assembly language.

Transcription:

Topic 1: Programming concepts Learning Outcomes Upon successful completion of this topic you will be able to: identify stages of a program development implement algorithm design techniques break down a problem into logical blocks describe different types of programming languages use pseudocode and flowchart to represent a complete solution describe and use a C++ IDE describe basic blocks of a C++ program. Introduction to the Topic Computers are instruments used by people to make their work performance faster and more accurate. Computers do not have an internal intelligence. Computers need programs, written by people, to tell them what to do and how to do it. In this topic you will learn how to analyse a program and write instructions (programs) that a computer understands. You will be introduced to C++, one of the most popular programming languages, and an Integrated Development Environment (Microsoft Visual Studio). Background Skills and Knowledge We assume that you understand basic computer operations, can use text editors and a file system. 1.1 Programming concepts and algorithm design techniques A computer program is a set of instructions that directs the CPU (Central Processing Unit) to perform some operations, like EEET 2280 Computing Engineering 27

adding two numbers, displaying a pop-up window, or playing a DVD. Program development always starts with analysing a problem and creating an algorithm of the solution. The algorithm describes all steps of the program s execution and their order. You can represent these steps using simple words or special symbols. The former presentation is called a pseudocode, and the latter a flowchart. You can write an algorithm for any task or procedure. There are four steps you need to follow when designing an algorithm: 1. Define the expected output 2. Work out the logic to get the output 3. Develop a pseudocode or flowchart of the algorithm. 4. Test the algorithm A programmer who uses structured programming divides a problem into smaller sub - problems or modules, and develops an algorithm of the solution for each of these modules. The complete solution is then created by combining individual algorithms. This approach is also called top-down design, or modular programming. You will find examples of structured algorithms designed using pseudocode and/or flowcharts, in the lecture notes: Reading 1 Read Herbert (2004), C++ A Beginner s Guide, pp 2 12 Deitel (2001), C++ How to Program, pp 2 15 Etter (2008), Engineering Problem Solving with C++, pp 3-30 EEET 2280 Computing Engineering 28

Activity 1.1 A Discussion/Problem solving In groups of 3 to 4 students, create an algorithm for the following tasks / procedures: 1. Making a cup of tea 2. Sending an SMS from your mobile 3. Calculating the average age of the students in your group 4. Finding the total resistance of three resistors connected in parallel. a. The program should ask a user to enter values for the resistors from the keyboard, and then display the result. b. To enhance your algorithm, continue requesting the values until the user terminates the program is a pre-defined way. Figure 1: Parallel connection of three resistors RMIT University, 2008 EEET 2280 Computing Engineering 29

1.2 Procedural and object-oriented programming C and C++ programming languages Information is stored and processed inside a computer as sequences of binary digits. These sequences consist of 1 s and 0 s, called bits, which form binary codes. A sequence of 8 binary digits makes a byte. A machine language provides instructions in bits. Assembly languages use mnemonics instructions that written in ordinary words like LOAD, ADD, etc., and a special program called assembler that translates them into binary codes. High-level programming languages use instructions that look more like natural language. Basic, FORTRAN, COBOL, Pascal, C, C++, and Java are high-level languages. C++ and Java originate from C. A C program has all the benefits provided by any high-level language, but can be executed much faster. In the 1980s C became the most popular structured programming language. C++ adds to the C language capabilities of objectoriented programming. Object-oriented design is based on identifying a problem s components (objects) and describing how these objects interact with each other. In this course you will initially use structured programming techniques to develop a C++ program. C++ programs written in this way can be run as C programs with a few modifications of the source code. From Topic 10 you will be introduced to the object-oriented features of this programming language. A program written in C++ is called a source code and, in a Windows environment is usually stored as.cpp file. You can use an ordinary text editor to write a C++ program. In this case you also need on your computer a special program called a compiler to translate the program into machine codes. The compiler program automatically runs a pre-processor program that performs pre-processor directives. In the final step you will build the program which includes calling a linker that connects the program code with C++ or other required libraries, and produces the executable file. The executable file usually has the same name as the source file and extension.exe. A set of programs required for the whole process depends on the platform, or operating system. EEET 2280 Computing Engineering 30

Activity 1.2 A Discussion/Research Using reference books or the Internet, answer the following questions: 1 What are the advantages of object oriented design compared to structured programming? 2 Why are C and C++ considered better programming languages to use in processing of large amounts of data than, for example, Java or C#? 3 Create a flowchart that illustrates the process of problem solving using a program written in C++. Which part of this flowchart will look different when the program is written in Java? 1.3 Integrated Development Environment (IDE) A C++ Integrated Development Environment includes all programs described above in a single software package. There are several popular C++ IDEs; some of them are freeware that you can download from the Internet (Dev C++), and some are powerful and quite expensive software applications (MS Visual Studio). In this course we have provided you with instructions of how to use both, Dev C++ (Using Dev-C++.pdf), and MS Visual Studio C++ (Using MS Visual Studio.pdf) to create a C++ project. Your teacher/instructor will specify which IDE is preferable to use in your course. ( Using Dev-C++.pdf and Using MS Visual Studio.pdf are located within Course Documents in Blackboard) EEET 2280 Computing Engineering 31

Every C++ program will usually include the following: comments to declare the purpose of the program, function or line, headers to provide necessary information about functions or constants (for example, call the pre-processor directive #include) a using statement(s) to notify the compiler that items from a particular namespace will be used. (For example, the statement using namespace std; makes all items from this namespace available without additional referencing) a main() function where the program execution starts and ends. Each line of the program that ends with a semicolon is called a statement. Each statement is meant to perform some task. Syntax rules define which statements are legal to use. Semantic rules determine the meaning of a statement. Program documentation is a significant part of any computer program. In complex C++ applications comments, and also programming style and naming conventions, play an important role in the program documentation and maintenance. Activity 1.3 A Discussion/Research Using the file hello.cpp look at the program Hello C++ and read the explanation of what each line of the program means. hello.cpp is within Course Documents in Blackboard EEET 2280 Computing Engineering 32

Activity 1 B Laboratory experiment Create a new folder on your Home network drive called C++, and a sub-folder C++\Topic 1. Follow instructions in the Lecture notes 1_3 to create a new project using a preferred IDE and save it in this sub-folder Open a source file and type in the program Hello C++. Note: copying text from MS Word will cause compiling errors, because of various extra characters used in Word (like, new line, etc.). Compile the program. Correct any syntax/linking errors. Run the program and observe the output. Make one change in the code (create an error by, for instance, removing a semicolon, or misspelling a keyword, or deleting a reference to namespace etc.). Repeat Step 4 and document the compiler s message. Correct errors and compile it again, and run. Repeat the last step several times. Add comments to the line which starts with cout to indicate what this line does. Describe two ways in which you can add a comment. Additional exercises: Write a C++ program that displays on the screen in three lines the program code and title, your name, and your student ID. Follow instructions in the textbook [1] complete Project 1-1 page 24. EEET 2280 Computing Engineering 33

Summary and Outcome Checklist In this topic you have learnt algorithm development techniques, discovered differences between programming languages, familiarised yourself with C++ IDE and you have written your first C++ program. Tick the box for each statement with which you agree: I can identify stages of a program development I can implement algorithm design techniques I can break down a problem into logical blocks I can describe different types of programming languages I can use pseudocode and flowchart to represent a complete solution I am familiar with C++ IDE I can describe basic blocks of a C++ program Assessment This topic will be assessed as part of the Major Assessment task 1 (see Assessment for more detail). This aims to ensure understanding of key concepts prior to undertaking the end of the semester examination. EEET 2280 Computing Engineering 34