Principles of computer programming. Profesor : doc. dr Marko Tanasković Assistent : doc. dr Marko Tanasković

Similar documents
CS 241 Data Organization. August 21, 2018

Administration Computers Software Algorithms Programming Languages

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

CS240: Programming in C

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

Computer Programming C++ (wg) CCOs

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

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

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

Spring 2018 NENG 202 Introduction to Computer Programming

PROGRAMMAZIONE I A.A. 2017/2018

CS 240 Fall 2015 Section 004. Alvin Chao, Professor

ENGINEERING PROGRAMMING

EL2310 Scientific Programming

William Paterson University of New Jersey Department of Computer Science College of Science and Health Course Outline

Chapter 2 Bits, Data Types, and Operations

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

ENGR/CS 101 CS Session Lecture 3

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

Assignment 1: Communicating with Programs

CS 211 Programming I for Engineers

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

0 Introduction: Computer systems and program development

Advanced Compiler Construction

SE311: Design of Digital Systems

Room 3P16 Telephone: extension ~irjohnson/uqc146s1.html

C Language, Token, Keywords, Constant, variable

The Gray Code. Script

Overview. Exercise 0: Implementing a Client. Setup and Preparation

Remaining Enhanced Labs

Introduction to Programming in Turing. Input, Output, and Variables

Life Cycle of Source Program - Compiler Design

Digital Systems COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

Python Programming Exercises 1

1.1 Information representation

Introduction to Basis and Practice in Programming

Introductory Lecture. CS319: Scientific Computing (with C++) Week 1: 11 Jan, Lecturer: Niall Madden.

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

Computer Science & Engineering 150A Problem Solving Using Computers

a name refers to an object side effect of assigning composite objects

Chapter 2 Bits, Data Types, and Operations

CMPUT 201: Practical Programming Methodology. Guohui Lin Department of Computing Science University of Alberta September 2018

Chapter 2 Bits, Data Types, and Operations

Computers and programming languages introduction

Computers Programming Course 5. Iulian Năstac

Unit 1: Introduction to Programming. Saurabh Khatri Lecturer Department of Computer Technology VIT, Pune

G. PULLAIAH COLLEGE OF ENGINEERING AND TECHNOLOGY Pasupula, Nandikotkur Road, Kurnool

CS 110 Computer Architecture. Lecture 2: Introduction to C, Part I. Instructor: Sören Schwertfeger.

CMPSCI 250: Introduction to Computation. Lecture #1: Things, Sets and Strings David Mix Barrington 22 January 2014

KULLEĠĠ SAN BENEDITTU Secondary School, Kirkop

SWEN-250 Personal SE. Introduction to C

a- As a special case, if there is only one symbol, no bits are required to specify it.

CS 240 Fall Mike Lam, Professor. Just-for-fun survey:

! Broaden your language horizons! Different programming languages! Different language features and tradeoffs. ! Study how languages are implemented

Chapter 2 Bits, Data Types, and Operations

LAB A Translating Data to Binary

Programming (Econometrics)

Interfacing with C++

Syllabus of ENPM 691: Secure Programming in C

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

Overview. Exercise 0: Implementing a Client. Setup and Preparation

More on Arrays CS 16: Solving Problems with Computers I Lecture #13

ALT-Assembly Language Tutorial

Lecture 1. Introduction to course, Welcome to Engineering, What is Programming and Why is this the first thing being covered in Engineering?

Chapter 3 DATA REPRESENTATION

9/3/2016. ECE 120: Introduction to Computing. Few Programmers Write Instructions (Assembly Code) Spend a Week Learning the C Programming Language

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

ECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION

Lecture 1: Preliminaries

ECE 250 / CS 250 Computer Architecture. C to Binary: Memory & Data Representations. Benjamin Lee

Thus needs to be a consistent method of representing negative numbers in binary computer arithmetic operations.

CS102 Unit 2. Sets and Mathematical Formalism Programming Languages and Simple Program Execution

Summary of Last Class. Processes. C vs. Java. C vs. Java (cont.) C vs. Java (cont.) Tevfik Ko!ar. CSC Systems Programming Fall 2008

Concepts in Programming Languages

CS120 Computer Science I. Instructor: Jia Song

Lecture 1 - Introduction (Class Notes)

Programming Language Basics

Operating System Labs. Yuanbin Wu

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

Programming (ERIM) Lecture 1: Introduction to programming paradigms and typing systems. Tommi Tervonen

Chapter 10 Binary Arithmetics

Final Labs and Tutors

Computer Principles and Components 1

CS 241 Data Organization using C

Introduction to C. CS 2060 Week 1. Prof. Jonathan Ventura. Outline Introduction Introduction to C Homework 1 C Coding Style Wrap-up

IBM 370 Basic Data Types

Hands-On Ethical Hacking and Network Defense 2 nd edition

Central Washington University Department of Computer Science Course Syllabus

Chapter 2: Programming Concepts

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers

Common Core State Standards Mathematics (Subset K-5 Counting and Cardinality, Operations and Algebraic Thinking, Number and Operations in Base 10)

EP241 Computer Programming

Slide Set 5. for ENCM 369 Winter 2014 Lecture Section 01. Steve Norman, PhD, PEng

C Programming for Engineers Introduction

BCIS 3630 Dr. GUYNES FALL 2014 MONDAY SECTION

CSC 015: FUNDAMENTALS OF COMPUTER SCIENCE I

COMP1917: Computing 1 1. Introduction

Software Lesson 2 Outline

Introduction to C CMSC 104 Spring 2014, Section 02, Lecture 6 Jason Tang

COMP1917: Computing 1 1. Introduction

Transcription:

Principles of computer programming Profesor : doc. dr Marko Tanasković Assistent : doc. dr Marko Tanasković E-mail: mtanaskovic@singidunum.ac.rs

Course organization Lectures: Presentation of concepts and their illustration through simple examples. The examples will be done in interaction with students Exercises: Practical application of the concepts through more complex examples

Lecture material Basic literature 1.) Lecture and exercise slides (course webpage http://predmet.singidunum.ac.rs/course/view.php?id=945) 2.) Book: The C Programming Language from Brian W. Kernighan and Dennis M. Ritchie (available on-line at http://cs.indstate.edu/~cbasavaraj/cs559/the_c_programming _language_2.pdf ) Additional literature 1.) Internet (Google as your best friend)

Assesment The progress of the students will be continuously monitored during the semester Students can maximally obtain 100 points for this course. Out of these 100 points, 70 can be won during the semester and 30 on the final exam Students will pass the exam by winning at least 51 points during the course. Points in the range 51-60 result in grade six, points in the range 61-70 result in grade seven

Assesment Final grade will be formed on the basis of obtained points according to the following scheme: 51-60 points grade 6 (six); 61-70 points grade 7 (seven); 71-80 points grade 8 (eight); 81-90 points grade 9 (nine); 91-100 points grade 10 (ten).

Semester progress assessment 1. Presence at lectures and exercizes (0-10 points) Students who are working and can not come to the lectures and exercises may still win these points by doing a project in agreement with the lecturer 2. Midterm I (0-30 points) student has to obtain at least 17 points in order to pass the first midterm 3. Midterm II (0-30 points) student has to obtain at least 17 points in order to pass the second midterm

Midterms The two midterms take place: I midterm in 6 th week of the semester II midterm in 12 th week of the semester During the second midterm, students can also do the first one, while at the final exam students can do both the first and the second midterm The midterms will consist of a written test and a mini project - Test is worth 20 points (10 are needed for a pass) - Mini project is worth 10 points and it is a take home task that students have one week to complete. It is defended orally by practically presenting the results

Final exam Final exam will be in a form of a take home project. Students will have two and a half weeks to complete the project The final project is defended orally by practically presenting the results Final exam is worth 30 points

Why should you invest your time in learning the material of this course??

The future of IT industry Whether you chose to study data science or embedded systems, you will profit from the future trends!

Where does the principles of computer programming fit in this story? Principles of computer programming lies in the fundamentals of both areas Dta Science Embedded Systems Domain specific knowledge Orogramming languages Databa ses Maths, Principles of programming

Why should you study this course? Form a good fundamental so that you can build your knowledge and expertize on top of it You will be able to profit from this knowledge later as you develop into software engineers!

Silabus Course outline Week I II III IV V VI VII VIII Team/Activity Introduction to principles of programming and the C programming language Types, operators and expressions Control flow Functions and program structures Pointers and arrays First Midterm Structures Input and output

Silabus Course outline Nedelja X XI XII XIII XIV XV Tema/Aktivnost The UNIX system interface Standard libraries Second Midterm Recapitulation, introduction to writting large projects in C Example of a complex programming project in C Example of a complex programming project in C, preparation for the final exam project

Principles of computer programming Profesor : doc. dr Marko Tanasković Assistent : doc. dr Marko Tanasković E-mail: mtanaskovic@singidunum.ac.rs

Definition of a computer Computer (noun) An electronic device which is capable of receiving information (data) in a particular form and of performing a sequence of operations in accordance with a predetermined but variable set of procedural instructions (program) to produce a result in the form of information or signals. Computer, Wikipedia definition A computer is a device that can be instructed to carry out arbitrary sequences of arithmetic or logical operations automatically. The ability of computers to follow generalized sets of operations, called programs, enables them to perform an extremely wide range of tasks.

Computer - examples

Definition of a computer program Computer program (noun) A sequence of instructions that a computer can interpret and execute Computer program, Wikipedia definition: A computer program is a collection of instructions that performs a specific task when executed by a computer. A computer requires programs to function and typically executes the program's instructions in a central processing unit

Computer program - examples

Definition of a programming language A programming language is a formal language that specifies a set of instructions that can be used to produce various kinds of output. Programming languages generally consist of instructions for a computer. Programming languages can be used to create programs that implement specific algorithms. Programming language is a language that a computer may understand. By learning different programming languages we become capable of telling the computer to do what we want it to do

What does a computer understand? Computers are binary machines they only work with binary data Binary states in computer are represented by presence and absence of voltage We usually denote these binary states by 1 and 0 A typical binary instruction that a computer would understand

Representation of characters in a computer Numbers and characters are also represented as binary sequences in a computer The ASCII standard defines binary sequences that correspond to the alphabet letters and other characters

Representation of numbers in a computer Same logic is used for binary numbers

Transformation from decimal to binary numbers LSB least significant bit (the most right digit) MSB most significant bit (the most left digit) Binary number: 101001

Representation of negative binary numbers How to represent -41? Use the most significant bit to indicate the sign 0 for positive numbers 1 for negative numbers Decimal number 41 --- Binary representation: 00101001 Decimal number -41 --- Binary representation: 10101001 Alternatively use complement Decimal number 41 --- Binary representation: 00101001 Decimal number -41 --- Binary representation: 11010110

Should we write our programs as binary instructions?

Should we write our programs as binary instructions? Writing programs as binary instructions would be very difficult Programs would be prone to errors and it would be almost impossible for humans to write large and complex computer programs in this way If programming was done through writing binary instructions, the IT industry would newer be in the state it is in now No need to write instructions as binary commands. For each computer architecture there is a finite set of commands that can be used to write instructions assembler

Should we write our programs in assembler?

Should we write our programs in assembler? An assembler is a low-level programming language for a computer, in which there is a very strong correspondence between the language and the architecture of the machine. Each assembly language is specific to a particular computer architecture Writing code in assembler is easier than writing binary instructions, but still making complex projects and discovering possible errors is very hard Programs written in assembler work only for the corresponding computer architecture. Porting assembler code is hard and programs have to be rewritten in order to work on other architectures

High level programming languages A high-level programming language is a programming language with strong abstraction from the details of the computer. Unlike low-level programming languages, it may use natural language elements and be easier to use. This makes the process of developing a program simpler and more understandable relative to a lower-level language. The amount of abstraction provided defines how "high-level" a programming language is A compiler translates a program in a high-level programing language to an assembler code for a given hardware platform. This makes programs written in high level languages easily portable

History of high level programming languages 1957 Fortran, first compiler 1958 Lisp 1959 COBOL 1964 BASIC 1970 Pascal 1972 C 1980 C++ 1991 Python 1993 R 1995 Java, Java script 1995 - PHP

Why start with C? C is not specialized to any particular area of application and is quite general, which makes it suitable for learning the fundamentals of computer programming C can be useful both in Embedded Systems and Data Science It is a high-level programming language, but still remains very close to hardware, which makes it very useful for programming in conditions of limited resources or in situations where the speed of execution is critical Most modern operating systems are written in C

Prepare the environment for your first program in C We will use Code::Blocks for writing our C programs (open source and freely available at http://www.codeblocks.org/) As a compiler we will use GNU GCC Compiler (open source and freely available at https://sourceforge.net/projects/mingw/)

1. Start code blocks Your first program in C 2. Start a new project (Files->New->Project) 3. Select Console Project and press Go

Your first program in C 3. Select C as your language of choice and click next

Your first program in C 4. Specify the name and location directory of your folder and click next

Your first program in C 5. Select GNU GCC Compiler and click finish

Your first program in C 5. Select GNU GCC Compiler and click finish

Your first program in C

Your first program in C Include libraries that allow you to write on the standard output (monitor)

Your first program in C Program in C is a function that is always called main. It takes no arguments and in this case returns zero

Your first program in C Blocks of code are delimited with large brackets { and } in C

Your first program in C Each command in C must end with ; Command printf prints its argument to the standard output (console/monitor). The argument of this function is the sentence Hello world! And at the end there is a special sign \n which brings the cursor to the new line

Compile and run your program Press the compile and run button

Result of the program execution You will further extend this program during the exercise class Have fun, programming is interesting!