Introduction to Basis and Practice in Programming

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

Computer Science & Engineering 150A Problem Solving Using Computers

Fundamentals of Programming (C)

EL2310 Scientific Programming

CS 113: Introduction to

Administration Computers Software Algorithms Programming Languages

EL2310 Scientific Programming

Fundamentals of Programming. Lecture 1: Introduction to C Programming

ITT Technical Institute. ET2560T Introduction to C Programming Onsite and Online Course SYLLABUS

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

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

0 Introduction: Computer systems and program development

Unit. Programming Fundamentals. School of Science and Technology INTRODUCTION

Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan

Introduction to C Programming

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

Spring 2018 NENG 202 Introduction to Computer Programming

CS133 C Programming. Instructor: Jialiang Lu Office: Information Center 703

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

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

Introduction to Operating Systems

COMP1917: Computing 1 1. Introduction

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

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

1.The First Instrument known in the history of computers was. a) Pascal s adding machine b) Napier s bones c) Abacus d) Analytical Engine

Chapter 1. The Big Picture

W1005 Intro to CS and Programming in MATLAB. Brief History of Compu?ng. Fall 2014 Instructor: Ilia Vovsha. hip://

COMP1917: Computing 1 1. Introduction

LECTURE/ STUDY NOTES ON C

CS 241 Data Organization. August 21, 2018

1. Introduction. Course Web Site. COMP1917: Computing 1. Textbook. Occupational Health and Safety (OHS)

CS240: Programming in C

CS Prof J.P.Morrison

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

COMPUTER - GENERATIONS

CS 211 Programming I for Engineers

Welcome to Solving Problems with Computers I

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

Introduction to C Language

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

Week 1 Introduction to Programming

Introduction to Computer Systems

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

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

SCSP Programming Technique C

CS 50 Introduction to Computer Science I

Introduction To Computers. About the Course

Course and Unix Intro

by Pearson Education, Inc. All Rights Reserved.

PROGRAMMAZIONE I A.A. 2017/2018

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

Welcome to COSC Introduction to Computer Science

Principles in Programming: Orientation & Lecture 1. SWE2004: Principles in Programming Spring 2015 Euiseong Seo

Operating Systems Concepts. CMPUT 379, Winter 2014 Section B1

EKT 120/4 Computer Programming KOLEJ UNIVERSITI KEJURUTERAAN UTARA MALAYSIA

C Programming for Engineers Introduction

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Chris Riesbeck, Fall Introduction to Computer Systems

Lecture 1: Preliminaries

CSC Operating Systems Fall Lecture - I Introduction. Tevfik Ko!ar. Louisiana State University. August 25 th, Contact Information

CS 61C: Great Ideas in Computer Architecture Lecture 2: Introduction to C, Part I

Chapter 1 Introduction to Computers and C++ Programming

SSE3044: Operating Systems

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

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

Computer Science 4500 Operating Systems. Welcome! In This Module. Module 1 Introduction, Overview and History

Principles in Programming: Orientation & Lecture 1. SWE2004: Principles in Programming Spring 2014 Euiseong Seo

Preview from Notesale.co.uk Page 6 of 52

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

COURSE OVERVIEW. Introduction to Computer Engineering 2015 Spring by Euiseong Seo

3/13/2012. ESc101: Introduction to Computers and Programming Languages

Multiple Choice Questions UNIT-I

Chapter 1 Introduction to Computers and C++ Programming

EP241 Computer Programming

Chapter 1: Introduction to Computers and Programming

Chapter 1 & 2 Introduction to C Language

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

CS 241 Data Organization using C

C Language, Token, Keywords, Constant, variable

Andrew S. Tanenbaum, Operating Systems, Design and Implementation, (Second Edition), Prentice Hall.

Introduction to Operating Systems. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Introduction. Computers, algorithms

Introduction to Operating Systems. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Computer Fundamentals

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

JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD I Year B.Tech-SYLLABUS COMPUTER PROGRAMMING

Inf2C - Computer Systems Lecture 1 Course overview & the big picture

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

CS120 Computer Science I. Instructor: Jia Song

C++ Programming Language Lecture 1 Introduction

Introduction to Computer Systems

Topic 1: Programming concepts

Chapter 1: Introduction to Computers

CSE3008: Operating Systems. Computer Systems Laboratory Sungkyunkwan University

Course Information and Introduction

AE Computer Programming for Aerospace Engineers

Course Syllabus of Microprocessor I (Fall 2006)

Chapter 1: Introduction to Computers. In this chapter you will learn about:

Programming for Engineers: Getting Started

CS 240 Fall 2015 Section 004. Alvin Chao, Professor

Transcription:

Introduction to Basis and Practice in Programming Fall 2015 Jinkyu Jeong (jinkyu@skku.edu) 1

Course Overview

Course Basics! Class hour GEDB029-45: Mon. 13:00 ~ 14:50 GEDB029-46: Tue. 13:00 ~ 14:50 1~2 hours lectures at 400112 2~3 hours lab at 400212! Instructor: Jinkyu Jeong jinkyu@skku.edu http://csl.skku.edu/people/jinkyu Office: #400626 in Semiconductor Bldg. Office hour: Thu. & Fri. 13:00 ~ 14:00! TA 한용섭, ysha812@gmail.com, #400621 in Semiconductor Bldg. 정기식, kisik@csl.skku.edu, #85533 in Corporate Collaboration Center 3

Prerequisites! Prerequisite Courses Engineering Computer Programming! Programming Skill Nothing You will learn how to program in C 4

Course Materials! Textbook A Book on C: Programming in C (4th Ed.), Al Kelley, Ira Pohl Addison-Wesley, 1998! References C by Dissection: The Essentials of C Programming (4th Ed.) Al Kelly, Ira Pohl, Addison Wesley, 2000 The C Programming Language Kernighan, Brian, and Dennis Ritchie, Prentice Hall, 1988. Introduction to Computer Science Using Python: A Computational Problem-Solving Focus Charles Dierbach, Wiley 2012! Course webpage http://csl.skku.edu/gedb029f15/overview 5

Grading! Exams 30% Final! Laboratory 30% Attendance Completion of programming exercises! Programming Assignments 30% Programming assignments (up to 4)! Participation & quiz 10% Homework & quiz Attendance 6

Academic Honesty! All work submitted for credit must be your original ones.! Cheating on lab or homework F grade and a report to the Dean! Cheating on examination report to the president of SKKU! No exception on dishonesty 7

Computers

Computers?! A general-purpose device that can be programmed to carry out a finite set of arithmetic or logical operations.! Since a sequence of operations can be readily changed, the computer can solve more than one kind of problem. 9

Conceptual Model of Computers! Turing Machine Tape Read-write head Table of Rules 10

History! The 1st generation: Vacuum tube MARK-1, 1941 ENIAC, 1946 Von Neumann: "Stored Program" EDSAC, 1949 EDVAC, 1951 UNIVAC 1, 1951 11

History! The 2nd generation: Transistor Transistor invented in 1954 Operating system, FORTRAN, COBOL, ALGOL! The 3rd generation: Integrated Circuit IC developed by Jack St. Clair Kilby, Texas Instruments in 1959 Nobel Prize laureate for Physics in 2000 12

History! The 4th generation: LSI, VLSI Large Scale Integrated circuit Minicomputers and micro computers appeared Network, Data Base system Computers became popular by PC 13

General Computer Architecture! von Neumann machine (Stored-program computer) Display, disks, keyboard, mouse, scan ner, printer, network, 14

Components of Computers! CPU (Central Processing Unit): the hardware within a computer system which carries out the instructions of a computer program by performing the basic arithmetical, logical, and input/output operations of the system. 15

Components of Computers! Memory: physical devices used to store programs (sequences of instructions) or data (e.g., program state information) on a temporary or permanent basis for use in a computer or other digital electronic device! Examples: RAM, ROM, Disks (HDD, SSD), 16

All you have to know about computers for C programming! Computers play with numbers only Everything is represented by numbers pictures, numbers, music Binary: bit, byte, word, half word 17

Computational Thinking

Computers! What a computer can do? Everything when you can explain exactly how to do E.g., check if a number is a prime! What a computer cannot do? Everything that you cannot explain exactly how to do E.g., Feeling, thinking,! What a computer can do better than you Compute things extremely faster than you can do 2.6 billion computations in one second 19

Problem Solving with Computers! You need a language to tell computers to do what you want Korean, English,... natural languages are used by human Find the 100 th prime number Very difficult for computers to understand Binary numbers are used by computers 00001111 10111111 01000101 11111000 00001111 10111111 01001101 11111000 Very difficult for human to understand 20

Programming Languages! A language that describes what to do for a computer! Machine language binary only an expert use it! Assembly language alphabet most embedded system! High-level language C, Java, C++,... Python, Matlab, most software 00001111 10111111 01000101 11111000 00001111 10111111 01001101 11111000 00000011 10100001 01100110 10001001 01000101 11111010 MOV AX, MIDSCORE MOV CX, FINALSCORE ADD AX CX MOV TOTALSCORE, AX TotalScore = MidScore + FinalScore; 21

Problem Solving with Computer: Example! Check if a number is a prime.! Tell me how to determine step by step. 2, 3, 5, 13, 89, 233, 1597, 28657, 514229, 433494437, 29 71215073, 99194894755497, 106634041749171059581572169, 22

Problem Solving with Computer: Example! Recall what a prime number is. A prime number is a natural number that has exactly two distinct natural number divisors : 1 and itself 23

Problem Solving with Computer: Example! A straightforward (simple?) version: Input x Check if 2 divides x. If True, x is not a prime Check if 3 divides x. If True, x is not a prime Check if k divdes x. If True, x is not a prime. If False, x is a prime.! What is k? the largest natural number which is at most " Think about why?? 24

Problem Solving with Computer: Example Start Declare x Input x 2 divides x? F 3 divides x? F 4 divides x? F 5 divides x?... T T k divides x? x is not a prime x is a prime Stop 25

Problem Solving with Computer: Example! A better version Line 1: Input x Line 2: Set k with " Line 3: Assign 2 to n. Line 4: If n > k, x is a prime and goto Line 8 Line 5: If n divides x, x is not a prime and goto Line 8 Line 6: Increase n by 1 Line 7: Goto Line 4 Line 8: Stop 26

Problem Solving with Computer: Example Start Declare n, k n > k? T x is a prime F Input x n divides x? T x is not a prime Set k with " F n n + 1 Stop Assign 2 to n 27

Programming! Flow chart: A type of diagram that represents an algorithm or process, showing the steps as boxes of various kinds, and their order by connecting these with arrows.! Why flow chart and algorithms? This diagrammatic representation can give a step-bystep solution to a given problem. Flowcharts are used in analyzing, designing, documenting or managing a process or program 28

Programs A sequence of instructions written for a computer to perform a specified task 29

Program! A list of instructions Start Declare n, k Input x Set k with the proper value Assign 2 to n #include <stdio.h> #include <math.h> main() { int n, k, x; scanf( "%d", &x ); k = sqrt(x); n = 2; lable1: if( n > k ) { printf( "%d is a prime\n", x ); goto lable2; } n > k? F n divides x? F n <- n + 1 T T x is a prime x is not a prime Stop if( x % n == 0 ) { printf( "%d is not a prime\n", x ); goto lable2; } n = n + 1; goto lable1; lable2: return; } 30

Programming! What are programs for? coding #include <stdio.h> #include <math.h> main() { int n, k, x; scanf( "%d", &x ); k = sqrt(x); n = 2; lable1: if( n > x ) { printf( "%d prime\n", x ); goto lable2; } n = n + 1; goto lable1; lable2: return; } compile 19055BCB 4B1B0FCF DD1B0FCD E4284728 971D0FCF 4F53A809 C2D60DCF E6AD8DAC 4F8F4C70 2A70C745 1304691D 41D0A321 2497AF80 91BFFFD AA68A890 B4AA1B71 C7524194 91275960 58995EC8 1B210846 351A8CEE run test.c test.exe Programming 31

Programming! What is programming? the process of designing, writing, testing, debugging, and maintaining the source code of computer programs! What is programming language? an artificial language designed to express computations that can be performed by a computer C, C++, Java, Perl, Basic, Pascal, Fortran, COBOL, 32

Homework! Hour of Code http://code.org Tutorials for beginners 33

Introduction to C Language

History of C Language! Developed at Bell Lab., 1972 for system-level programming.! Used for implementing Unix OS! BCPL (Basic Combined Programming Language) " B language (Ken Thompson) " C language (Dennis Ritchie) 35

History of C Language! 1972: developed by Dennis Ritchie To develop an OS(Unix) for PDP-11 Small and efficient! 1989: ANSI C Portable (= C90 by ISO)! C99 By ISO Not by MS! C11 By ISO 36

Advantages of C Language! Efficient Developed for low-level (machine-level) execution! Portability Applicable to virtually all platforms from PCs to Supercomputers! Powerful Provides various data types and operators! Flexibility Applicable from system-level to application-level programming! Many Standard Libraries Input/Output, String handling, Storage allocation, 37

Disadvantages of C Language! Error Prone Difficult to detect errors resulting from its flexibility! Difficulty Difficult to understand and modify it due to many functionalities 38

Programming Development Cycle! Making goals Understanding of requirements in given problems! Writing algorithms Writing pseudo codes or flow charts! Coding Translate the algorithm to C programming language! Compile & Link Translate a C program to machine codes! Execution & Debugging Test whether the program generates correct results Modifying programs to correct errors found in testing! Maintenance Keep improving and fixing issues in the program 39

Programming Tools! Text Editor Store the written program (a simple text file) to storage Replace the extension with c (e.g., filename.c) Use vi or emacs editor on Unix Source file means a human-readable code before compiling it! Preprocessor As a part of compiler, it processes the lines beginning with # in the source code before compiling the source code 40

Programming Tools! Compiler (& linker) Check the syntax of a source program and convert it to a machine-understandable (executable) binary language source program executable program (***.c) compiler (~.exe) (a.out) 41

Building Executable Program Source File Preprocessed Source File Object File Executable File Preprocessing Compile Link Preprocessor Compiler Linker Header File Library 42