Week 1 Introduction to Programming

Similar documents
Week 3 Decision Structures

CME 112- Programming Languages II. Week 4 Pointers

Assist. Prof. Dr. Caner ÖZCAN

CME111 Programming Languages I. Week 10 Arrays. Assist. Prof. Dr. Caner ÖZCAN

CME 112- Programming Languages II. Week 1 Introduction, Scope Rules and Generating Random Numbers

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

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

Zimmer CSCI /24/18. CHAPTER 1 Overview. COMPUTER Programmable devices that can store, retrieve, and process data.

Microprocessors I MICROCOMPUTERS AND MICROPROCESSORS

CC411: Introduction To Microprocessors

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

بسم اهلل الرمحن الرحيم

Chapter One. Introduction to Computer System

Dec Hex Bin ORG ; ZERO. Introduction To Computing

Computer Fundamentals

Ms. Minerva A. Lagarde

CMSC 104 -Lecture 2 John Y. Park, adapted by C Grasso

COMPUTER BASICS Processing/Storage

Components of a personal computer

Components of a Computer System

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

Fundamental of digital computer

Computer Organization

Chapter 2: Computers: The Machines Behind Computing.

An Overview of the Computer System. Kafui A. Prebbie 24

Sir Sadiq s computer notes for class IX. Chapter no 4. Storage Devices

ELEG3923 Microprocessor Ch.0 & Ch.1 Introduction to Microcontroller

What is the typical configuration of a computer sold today? 1-1

Introduction to Computers

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.

Fundamentals of Programming. Lecture 1: Introduction to C Programming

INFORMATION COMUNICATION TECHNOLOGY SKS Lecture Two

TUTORIAL Describe the circumstances that would prompt you to use a microprocessorbased design solution instead of a hard-wired IC logic design.

Lecture 01: Basic Structure of Computers

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

v.m.g.rajasekaran ramani sri sarada sakthi mat. Hr. sec. school

Introduction to Computers

Chapter 1 Basic Computer Organization

SYSTEM BUS AND MOCROPROCESSORS HISTORY

Introduction to computers

Chapter 1. Computer System Organization

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

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

History. 3rd Generation- Integrated Circuits, Transistors (Integrated Circuit form) for Memory ( memory is now volatile), Terminal/Keyboard for I/O

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

Computer Organization and Assembly Language (CS-506)

A Review of Chapter 5 and. CSc 2010 Spring 2012 Instructor: Qian Hu

SCSP Programming Technique C

Java and Software Design

C++ Programming Language Lecture 1 Introduction

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

Computer Science & Engineering 150A Problem Solving Using Computers

Computer Basics. Computer Technology

Hardware. ( Not so hard really )

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

Chapter 3 Structured Program Development

Computer Fundamentals

System Unit. By: Khadeeja Farkash

Introduction to Basis and Practice in Programming

Homeschool Enrichment. The System Unit: Processing & Memory

Designing Computers. The Von Neumann Architecture. The Von Neumann Architecture. The Von Neumann Architecture

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

The Von Neumann Architecture. Designing Computers. The Von Neumann Architecture. CMPUT101 Introduction to Computing - Spring 2001

Introduction to Computer Systems and Operating Systems

2011 Francisco Delgadillo

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

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Introduction to Computing Module No: CS/ES/1 Quadrant 1 e-text

CMPUT101 Introduction to Computing - Summer 2002

Computer Architecture 2/26/01 Lecture #

CS 101, Mock Computer Architecture

Lecture 1: CS2400 Introduction to Computer Science

CHAPTER 1 Introduction to Computers and Java

HARDWARE AND OPERATING SYSTEMS

COSC 122 Computer Fluency. Computer Organization. Dr. Ramon Lawrence University of British Columbia Okanagan

The Programming Process Summer 2010 Margaret Reid-Miller

Angel International School - Manipay 1 st Term Examination November, 2015 ICT

Memory Overview. Overview - Memory Types 2/17/16. Curtis Nelson Walla Walla University

ST. MARY S COLLEGE FORM 4

Machine Architecture and Number Systems CMSC104. Von Neumann Machine. Major Computer Components. Schematic Diagram of a Computer. First Computer?

Computers 101. Lecture 1

Agenda EE 224: INTRODUCTION TO DIGITAL CIRCUITS & COMPUTER DESIGN. Lecture 1: Introduction. Go over the syllabus 3/31/2010

P-2 Digital Design & Applications

Chapter 4 Main Memory

St. Benedict s High School. Computing Science. Software Design & Development. (Part 2 Computer Architecture) National 5

Lecture (01) Digital Systems and Binary Numbers By: Dr. Ahmed ElShafee

An Introduction to Computers and Java CSC 121 Spring 2015 Howard Rosenthal

Chapter Two. Hardware Basics: Inside the Box

Test Bank for Prelude to Programming Chapter 0

Machine Architecture. or what s in the box? Lectures 2 & 3. Prof Leslie Smith. ITNP23 - Autumn 2014 Lectures 2&3, Slide 1

lesson 3 Transforming Data into Information

LOGIC DESIGN. Dr. Mahmoud Abo_elfetouh

Notes - Computer Hardware Basics

CC312: Computer Organization

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation

3.1 Description of Microprocessor. 3.2 History of Microprocessor

Contents: Computer definition Computer literacy Computer components Computer categories Computer usage. Tablet PC

Computer System. Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

INTRODUCTION TO INFORMATION & COMMUNICATION TECHNOLOGY (ICT) LECTURE 2 : WEEK 2 CSC-111-T

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

Chapter 1 : Introduction

Transcription:

CME111 Programming Languages I Week 1 Introduction to Programming Assist. Prof. Dr. Caner ÖZCAN

Introduction Course Web Site: www.canerozcan.net Office Hours: Tuesday 13:00-15:00 Wednesday 15:30-17:00 or appointment by email: canerozcan@karabuk.edu.tr Textbooks: Doç. Dr. Fahri Vatansever, Algoritma Geliştirme ve Programlamaya Giriş, Seçkin Yayıncılık, 12. Baskı, 2015 Brookshear J. G., Computer Science: An Overview, Pearson International Edition, 2007 2

Introduction Work hard and practice! Grading Visa Exam: %40 Final Exam: %60 Study to learn, not for grade. Grade is already won. 3

Term Topics Lecture 1- Basic Concepts and Algorithm Lecture 2- Variable and Operators Lecture 3- Control Structures Lecture 4- Repetition Structures Lecture 5- Algorithm Examples and Analysis-1 Lecture 6- Algorithm Examples and Analysis-2 Lecture 7- Introduction to C Programming and C Compiler Lecture 8- Basic Data Types of C and Input/Output Operations (printf, scanf) Lecture 9- Control and Repetition Structures of C Lecture 10- Arrays Lecture 11- Character Arrays Lecture 12- Functions-1 Lecture 13- Functions-2 4

What is Computer? A computer is a device capable of performing computations and making logical decisions. Today s supercomputers can perform trillions of additions per second. A computer is comprised of various devices (such as the keyboard, screen, mouse, disks, memory, DVD, CD-ROM & processing units) that are referred to as hardware. Computer programs that run on a computer are referred to as software. 5

What is Computer? One of the earlier computing devices was the abacus. 6

What is Computer? Advancements on computer technology chronologically: B.C. 500 Abacus 1642 Pascal's Mechanical Addition Machine 1827 Babbage's subtraction machine 1941 Binary Mechanical Calculator (Zuse) 1944 Decimal Electromechanic Calculator (Aiken) 1945-54 First Generation Vacuum Tubes and Beams 1955-64 Second Generation Transistors and Magnetic Memories 1965-71 Third Generation Integrated Circuits 1971-90 Fourth Generation VLSI Circuits 1982 IBM Pc & MS-DOS 1984 MAC 1990 s Parallel Processors 7

What is Computer? IBM MARK-I 8

What is Computer? ENIAC- Electronic Numerical Integrator And Computer 9

Computer Organization Central Processing Unit Main Memory Register Unit Arithmetic/ Logic Unit BUS Control Unit... 10

Computer Organization CPU (Central Processing Unit- also called Processor). Early CPUs were large units (perhaps several racks of electronic circuitry) CPUs in todays PCs are packaged as small flat square (2x2 inches). CPUs are placed on the motherboard. Processors are also called microprocessors due to their small size 11

Computer Organization CPU consists of three parts: Arithmetic/logic unit, Control unit and Register unit Arithmetic / logic unit contains the circuitry that performs operations on data (such as addition and subtraction); Control unit contains the circuitry for coordinating the machine s activities; Register unit contains data storage cells (similar to main memory cells) called registers that are used for temporary storage of information within the CPU. 12

Computer Organization Memory: Permanent or temporary storage environment. RAM (Random Access Memory): RAM is normally associated with volatile types of memory where stored information is lost if power is removed. RAM is also called Main memory. ROM (Read Only Memory): Other types of nonvolatile memories exist that allow random access for read operations, but either do not allow write operations. 13

Computer Organization General purpose registers serve as temporary holding places for data being manipulated by the CPU. These registers hold the inputs to the arithmetic/logic units' circuitry and provide storage space for results produced by that unit. To perform an operation on data stored in main memory, the control unit transfers the data from memory into the general purpose registers, informs the arithmetic/logic unit, and tells the arithmetic/logic unit which registers should receive the results. 14

Computer Organization For the purpose of transferring bit patterns, a machine s CPU and main memory are connected by a collection of wires called a bus. Through this bus, the CPU extracts (reads) data from main memory by supplying the address of the pertinent memory cell along with an electronic signal telling the memory circuitry that it is supposed to retrieve the data in the indicated cell. In a similar manner, the CPU places (writes) data in memory by providing the address of the destination cell and data to be stored together with the appropriate electronic signal telling main memory that is supposed to store the data being sent to it. 15

Data Storage Units All data in computer systems are stored in electrical signals represented by binary 1 or 0. Each digit in binary system is called bit. Bit is not enough to express a quantity. We use byte as basic memory unit. 1 byte = 8 bits Each character in computer system is represented by 8 bits. Example: Character A is represented as 0100001 in binary. Each digit of this number is called bit. 16

Data Storage Units Data storage units are as follows from lowest to highest: Bit, Byte,KB(Kilo Byte), MB (Mega Byte), GB (Giga Byte), TB (Tera Byte). 1 Byte=8 Bits 1 KB (Kilo Byte)=1024 Byte 1 MB (Mega Byte)=1024 KB 1 GB (Giga Byte)=1024 MB 1 TB (Tera Byte)=1024 GB 17

Programming Language Unlike human being, computers do not have a functional brain. That is why we should give commands to do something with computers. Programming Language: Formal computer language designed to communicate instructions to a machine, particularly a computer. 18

Programming Language [kaynak]http://tr.wikipedia.org/wiki/programlama_dili

Programming Language [1]http://rigaux.org/language-study/diagram.html

What is program? There are variety of program types according to purpose of their usage : System programs: Every program runs on an operating system. Operating system provides resources and environment for other softwares. Drivers: Programs that allows communication between operating system and hardware. Applications: Programs that run on an operating system for meeting users requirements. 21

Who is programmer? Programmer, is a person who writes computer software. Programmer should know about platforms that is used for developing programs. Programmers: Builder: Determines the necessary technologies for writing the program. Developer: Person that writes programs. Analyst: Person who tries to find out error and report them to coders during development process. 22

Classification of Programming Languages Programming languages can be grouped according to their levels which is a measure of proximity for human perception. High level languages are close to human perception whereas low level languages are close to computer hardware. As level of programming language increase, things get easier for a programmer. The higher programming language makes the jobs easier but reduces the efficiency and flexibility in general. 23

Classification of Programming Languages 24

Classification of Programming Languages Machine Language Natural language of a computer Consist of strings of numbers (mostly reduced to 1 & 0) Machine dependent Low Level Language (Assembly Language) English-like abbreviations to represent elementary operations. Assemblers were developed to convert assembly language programs to machine language. 25

Classification of Programming Languages Any computer can directly understand only its own machine language. Machine language is the natural language of a computer and as such defined in its hardware. Machine languages generally consist of strings of numbers (mostly reduced to 1s and 0s) that instruct computers to perform their most elementary operations. Machine languages are machine dependent. 26

Classification of Programming Languages Machine language programming was simply too slow and tedious for most programmers. Instead using the strings of numbers that computers directly understand programmers began using English-like abbreviations to represent elementary operations. These abbreviations formed the basis of assembly language. Assemblers were developed to convert assembly language programs to machine language. 27

Classification of Programming Languages Medium Level Languages Close to both human and computer Easy like high level languages, flexible like low level languages. Generally used for system programming. C is a medium level language. High Level Languages To speed the programming task Compilers convert high level language programs into machine language. Code similar to everyday English Interpreter programs developed to execute high level languages without need of compiling 28

Classification of Programming Languages Very High Level languages allows to write programs almost visually using some tools. Languages such as C# and Visual Basic are used very often on Windows systems. Very high level languages are also called declarative languages. Languages that is used to manage database systems can be put in this group. 29

Compilers and Interpreters Translator programs that convert high level language programs into machine language are called compilers. High level languages allow programmer to write instructions that look almost like everyday English and contain commonly used mathematical notations. Interpreter programs were developed to execute high-level language programs without the need for compiling them into machine language. Although compiled programs run faster than interpreted programs, interpreters are popular in program development environments. 30

Compilers and Interpreters Compilers firstly controls the written code. If code has errors, compiler stops process. When all errors are removed from code, compiler converts the code into machine code (exe file) Interpreters execute code row by row instead of compiling it totally. 31

Computers - Review 32

Data Storage Units - Review 33

Why programming is important? Review 34

Problem and Problem Solving The idea of achieving an automation or solving a scientific computation using computers is called a problem. It is essential to have a thorough understanding of the problem and a carefully planned approach to solving the problem. A problem may have more than one solution. In this case we should find an optimal solution with computers. 35

Algorithm Algorithm: A procedure for solving problem in terms of The action to be executed The order in which these actions are to be executed.. All steps should be decisive. Nothing should be related with chance. Algorithm should end in a finite step. Algorithms should handle all possible cases. Algorithms are expressed with pseudo codes or flow charts. 36

Algorithm 37

Pseudo Code Pseudo code is an artificial and informal language that helps developing algorithms. Pseudo code is similar to everyday English; Convenient User friendly Not an actual programming language. Not executed on computers. They help you think out a program before attempting to write it. Only consist of action statements. 38

Pseudo Code Basic pseudo code commands Start : It indicates that the program has started. End : It indicates that the program has finished. Read : It is written for user input. Print : It is written to show users the information or results. If Else : It used in the change of flow according to the conditions. 39

Flow charts Flowchart is a graphical representation of an algorithm or of a portion of an algorithm. Flowcharts are drawn using certain special purpose symbols such as Rectangles, Diamonds, Ovals, Small circles Action Symbol Start/End Connector Decision Symbol 40

Control Structures Researches have shown that programs could be written without any go to statement in terms of only three control structures, namely sequence structure, the selection structure and repetition structure. Control Structures Sequence Structure Selection Structure Repetition Structure 41

Control Structures Sequence Structure Statements in a program executed one after the other in the order in which they are written Unless directed otherwise the computer automatically executes C statements one after the other in the order in which they are written. We use rectangle symbol also called action symbol, to indicate any type of action including a calculation or input/output operation. Add grade to sum Increment counter toplam = toplam + not sayac = sayac + 1 42

Control Structures (Sequence Structure) Example; if an aircraft wants to throw a missile to a target, steps should be as follows. If steps are not followed in order, process will fail. 1. Get the coordinates of the target 2. Get the current coordinate of aircraft 3. Perform calculation to hit the target. 4. Fire missile. 43

Control Structures 1. Refinement of the first step: a. Get coordinates from officer b. Be sure that target coordinates are valid. c. Store coordinates in memory. a. Refinement of sub step "a" i. Be sure of coordinates ii. Control whether target is the range of missile. iii. Control whether target is friend area or not. 44

Algorithm Basically, algorithms have three main parts : Input: Data that computer will work on is put by a user. Process: Computer processes data. Output: Computer shows results in a way that people can understand. 45

Algoritma Input: a. Get product name. b. Get amount of product. c. Read price of product from a file Process: a. Calculate the total price of the product b. Give discount Output: a. Print final price Final algorithm: 1. Start. 2. Get product name. 3. Get amount of product. 4. Read price of product from a file 5. Calculate the total price of the product 6. Give discount 7. Print final price 8. End 46

Algorithm 47

References Doç. Dr. Fahri Vatansever, Algoritma Geliştirme ve Programlamaya Giriş, Seçkin Yayıncılık, 12. Baskı, 2015 J. G. Brookshear, Computer Science: An Overview 10th Ed., Addison Wisley, 2009 Kaan Aslan, A dan Z ye C Klavuzu 8. Basım, Pusula Yayıncılık, 2002 Paul J. Deitel, C How to Program, Harvey Deitel. 48