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

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

Fundamentals of Programming. Lecture 1: Introduction to C Programming

Chapter 1 Introduction to Computers and C++ Programming

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.

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

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

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

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

IS 0020 Program Design and Software Tools

Week 0: Intro to Computers and Programming. 1.1 Why Program? 1.2 Computer Systems: Hardware and Software. Hardware Components

Chapter 1 Introduction to Computers and C++ Programming

0 Introduction: Computer systems and program development

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

Chapter 1 INTRODUCTION

Chapter 1: Introduction to Computers and Programming

Chapter 1 Introduction to Computers and Programming

Introduction. Arizona State University 1

INTRODUCTION TO THE COURSE

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

Week 1 Introduction to Programming

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

Problem Solving With C++ Ninth Edition

Understanding main() function Input/Output Streams

EKT 120/4 Computer Programming KOLEJ UNIVERSITI KEJURUTERAAN UTARA MALAYSIA

Introduction to Computers

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

Introduction to Programming

Fundamentals of Programming (C)

Welcome to Solving Problems with Computers I

Fundamentals of Programming Session 1

Fundamentals of Programming Session 1

Computer Programming : C++

Week 1 Introduction to Computer and Algorithm (Part1) UniMAP Sem II 11/12 DKT121: Basic Computer Programming 1

Object Oriented Design

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

Chapter 1. Computer Technology Concept of Programming & Algorithm and Flow Charts

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

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

Welcome (back) to CS1007!

CHAPTER 3 BASIC INSTRUCTION OF C++

SCSP Programming Technique C

CSCE150A. Administrivia. Overview. Hardware. Software. Example. Program. Pseudocode. Flowchart. Control Structures. Hello World Program CSCE150A

Computer Science & Engineering 150A Problem Solving Using Computers

1a Computers, Problem Solving!

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

Chapter 1 Introduction to Computers and C++ Programming

Welcome to MCS 360. content expectations. using g++ input and output streams the namespace std. Euclid s algorithm the while and do-while statements

Computer Programming

Computer Fundamentals

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

First C or C++ Lab Paycheck-V1.0 Using Microsoft Visual Studio

Programming - 1. Computer Science Department 011COMP-3 لغة البرمجة 1 لطالب كلية الحاسب اآللي ونظم المعلومات 011 عال- 3

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

2 nd Week Lecture Notes

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

Chapter 1 Computer and Programming. By Zerihun Alemayehu

Starting Out with C++: Early Objects, 9 th ed. (Gaddis, Walters & Muganda) Chapter 2 Introduction to C++ Chapter 2 Test 1 Key

Fundamentals of Programming Session 4

Computer Science II Lecture 1 Introduction and Background

Computer Programming. Dr. Fahad Computer Science Deptt.

Fundamentals of Structured Programming

Fundamentals of Programming Session 2

Chapter 2: Introduction to C++

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

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

A A B U n i v e r s i t y

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

CC411: Introduction To Microprocessors

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

4. Structure of a C++ program

The C++ Language. Arizona State University 1

Introduction to C++ Programming Pearson Education, Inc. All rights reserved.

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

INFS 214: Introduction to Computing

C H A P T E R 1. Introduction to Computers and Programming

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

CS150 Introduction to Computer Science 1. What is CS150? Who Are We? CS150 is a programming course You will learn

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

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming

Computer Architecture. Fall Dongkun Shin, SKKU

Today. An Animated Introduction to Programming. Prerequisites. Computer programming

Parts are adapted from Windows 98 by Mark Twain Media, Inc. A Computer System has Hardware and Software

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

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

CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING. Dr. Shady Yehia Elmashad

Computer is an electronic machine that can receive, store, transform and output data of all kinds (image, text, numeric, graphics and sound).

Scientific Computing

COMP322 - Introduction to C++ Lecture 01 - Introduction

LECTURE 02 INTRODUCTION TO C++

Introduction to C Programming 計算機程式設計

CS2303 C14 Systems Programming Concepts. Bob Kinicki

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

CSCI 1061U Programming Workshop 2. C++ Basics

Electricity: Voltage. Gate: A signal enters the gate at a certain voltage. The gate performs operations on it, and sends it out was a new signal.

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

Lecture 01: Basic Structure of Computers

Welcome to Computer Organization and Design Logic CS 64: Computer Organization and Design Logic Lecture #1 Winter 2018

Lecture 5. Review from last week. Selection Statements. cin and cout directives escape sequences

Transcription:

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

Syllabus Instructor: Asst. Prof. Dr. Santi Phithakkitnukoon ผศ.ดร.ส นต พ ท กษ ก จน ก ร (อ.เอ ม) Office room: 510 Lecture time: Wed 1pm-2pm Lecture room: 302 Lab time: Mon 2pm-9pm Required textbooks: None Suggested textbook: Paul Deitel and Harvey Deitel (2012), C++ How to Program (Eighth Edition), Prentice Hall. Course content: Basic computer programming (C++) Grading: Midterm exam 30% Final exam 30% Lab assignments 20% Quizzes 20%

What is Computer Engineering? Engineering designing and building systems Computer Engineering designing and building Computer systems ISNE designing and building Information and Network systems To design and build a computer system, we need to be able to instruct the computers.

What is a Computer? A computer is a device capable of performing computations and making logical decisions under the control of sets of instructions called computer programs. These programs guide the computer through orderly sets of actions with instructions specified by people called computer programmers. A computer is comprised of various devices (such as keyboard, screen, mouse, disks, memory, CD-ROM, and processing units) that are referred to as hardware. The computer programs that run on a computer are referred to as software.

Computer Organization 1. Input unit 2. Output unit 3. Memory unit 4. Arithmetic and logic unit (ALU) 5. Central processing unit (CPU) 6. Secondary memory unit

Computer Organization 1. Input unit This is the receiving section of the computer. It obtains information (data and computer programs) from input devices and places this information at the disposal of the other units for processing. Most information is entered into computers through keyboards, touch screens and mouse devices.

Computer Organization 2. Output unit This is the shipping section of the computer. It takes information that has been processed by the computer and places it on various output devices to make the information available for use outside the computer. Most information that s output from computers today is displayed on screens, printed on paper, played as audio or video on portable media players, and transmitted over the Internet.

Computer Organization 3. Memory unit The is the rapid access, relatively low-capacity warehouse section of the computer. It is the area in a computer in which data is stored for quick access by the computer processor (CPU) The memory unit is often called either memory or primary memory. The term Random Access Memory (RAM) is also associated with it. Typical main memories on desktop and notebook computers contain between 1 GB and 8 GB (GB stands for gigabytes; a gigabyte is approximately one billion bytes).

Computer Organization 4. Arithmetic and logic unit (ALU) This is the manufacturing section of the computer. It is responsible for performing calculations such as addition, subtraction, multiplication, and division. It contains the decision mechanisms that allow the computer, for example, to compare two items from the memory unit to determine whether or not they are equal.

Computer Organization 5. Central processing unit (CPU) This is the administrative section of the computer. It is the computer s coordinator and is responsible for supervising the operation of the other sections.

Computer Organization 6. Secondary storage unit This is the long-term, high-capacity warehousing section of the computer. Programs or data not actively being used by the other units are normally placed on secondary storage devices (such disks) until they are again needed later. Information in secondary storage takes much longer to access than information in primary memory. Examples of secondary storage devices include CD drives, DVD drives and flash drives, some of which can hold up to 128 GB. Typical hard drives on desktop and notebook computers can hold up to 2 TB (TB stands for terabytes; a terabyte is approximately one trillion bytes).

Computer Languages Programmers write instructions in various programming languages, some directly understandable by computers and others requiring intermediate translation steps. Hundreds of such languages are in use today. These may be divided into three general types: 1. Machine languages 2. Assembly languages 3. High-level languages

Computer Languages Any computer can directly understand only its own machine language, defined by its hardware design. Machine languages (or machine codes) generally consist of strings of numbers (ultimately reduced to 1s and 0s) that instruct computers to perform their most elementary operations one at a time. For example, here s a section of an early machine-language program that adds overtime pay to base pay and stores the result in gross pay: +1300042774 +1400593419 +1200274027

Computer Languages Programming in machine language was simply too slow and tedious for most programmers. Instead of using the machine code that computers could directly understand, programmers began using English-like abbreviations to represent elementary operations. These abbreviations formed the basis of assembly languages. Translator programs called assemblers were developed to convert early assembly-language programs to machine language. The following section of an assembly-language program also adds overtime pay to base pay and stores the result in gross pay: load add store basepay overpay grosspay

Computer Languages Although the assembly language is clearer to humans, it s still difficult to write instructions to accomplish an easy task. To speed up the programming process, high-level languages were developed in which single statements could be written to accomplish substantial tasks. Translator programs called compilers convert high-level language programs into machine language. High-level languages allow you to write instructions that look almost like everyday English and contain commonly used mathematical notations. A payroll program written in a high-level language might contain a single statement such as grosspay = basepay + overtimepay

High-level Languages From the programmer s standpoint, high-level languages are more preferable than machine and assembly languages. C++, C, Python, PHP, and Java are among the most widely used high-level programming languages.

Elements of Computer Programming 1. Editor source code editor 2. Compiler a program that translates a high-level language into machine code 3. Debugger a program that assists in the detection and correction of errors in computer programs.

Integrated Development Environment (IDE) An integrated development environment (IDE) or interactive development environment is a software application that provides comprehensive facilities to computer programmers for software development. IDE consists of source code editor, compiler, and debugger.

A Simple Program

A Simple Program Line 1: is a preprocessor directive a message to the C++ preprocessor. Lines that begin with # are processed by the preprocessor before the program is compiled. This line notifies the preprocessor to include in the program the contents of the input/output stream header <iostream>. This header must be included for any program that outputs data to the screen or inputs data from the keyboard using C++ s stream input/output.

A Simple Program Line 3: is part of every C++ program. The parentheses after main indicate that main is a program building block called a function. C++ programs typically consist of one or more functions and classes. Exactly one function in every program must be named main. The keyword int indicates that main returns an integer (whole number) value. The left brace, {, (line 4) must begin the body of every function. A corresponding right brace, }, (line 8) must end each function s body.

A Simple Program Line 5: instructs the computer to print the string of characters contained between the double quotation marks (Hello World!). The entire line is called statement. Every C++ statement must end with a semicolon (;) Output and input in C++ are accomplished with streams of characters. Thus, when this statement is executed, it sends the stream of characters Hello World! to the standard output stream object std::cout which is normally connected to the screen.

A Simple Program Line 5: The std:: before cout is required when we use names that we ve brought into the program by the preprocessor directive #include <iostream>. The notation std::cout specifies that we are using a name, in this case cout, that belongs to namespace std. For now, you should simply remember to include std:: before each mention of cout and cin.

A Simple Program Line 7: is one of several means we ll use to exit a function. When the return statement is used at the end of main, the value 0 indicates that the program has terminated successfully.

Hello World! Run this program. Modify it. Comment it. Make an error. Can you print your name on one line and Chiang Mai University on the next line?