COMP1917: Computing 1 1. Introduction

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

COMP1917: Computing 1 1. Introduction

EL2310 Scientific Programming

EL2310 Scientific Programming

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

PROGRAMMAZIONE I A.A. 2017/2018

Course Information and Introduction

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

introduction week 1 Ritsumeikan University College of Information Science and Engineering Ian Piumarta 1 / 20 imperative programming about the course

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

C Introduction. Comparison w/ Java, Memory Model, and Pointers

Structure of this course. C and C++ Past Exam Questions. Text books

Computers and Computation. The Modern Computer. The Operating System. The Operating System

CS 211 Programming I for Engineers

Programming in C and C++

(heavily based on last year s notes (Andrew Moore) with thanks to Alastair R. Beresford. 1. Types Variables Expressions & Statements 2/23

C Programming for Engineers Introduction

Programming in C and C++

Spring 2018 NENG 202 Introduction to Computer Programming

Software Project. Lecturers: Ran Caneti, Gideon Dror Teaching assistants: Nathan Manor, Ben Riva

CSE 303 Lecture 8. Intro to C programming

CS19001/CS19002 Programming and Data Structures Lab Autumn/Spring Semester. Introduction. Abhijit Das. January 4, 2015

Introduction to Basis and Practice in Programming

Introduction to C Programming

CS11001/CS11002 Programming and Data Structures Autumn/Spring Semesters. Introduction

CS11002 Programming and Data Structures Spring Introduction

COMP s1 Lecture 1

CS 253: Intro to Systems Programming 1/21

Introduction to Computing Lecture 01: Introduction to C

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

Programming. Data Structure

LECTURE/ STUDY NOTES ON C

CS 113: Introduction to

Programming in C. What is C?... What is C?

Programming in C UVic SEng 265

Module Syllabus. PHILADELPHIA UNIVERSITY Faculty: Information Technology Department: Applied Computer Science

Introduction to Computer Systems

Programming in C. What is C?... What is C?

Algorithms, Data Structures, and Problem Solving

Introduction to C Programming

C++ Programming for Programmers

B. Subject-specific skills B1. Problem solving skills: Supply the student with the ability to solve different problems related to the topics

Presented By : Gaurav Juneja

Welcome to... CS113: Introduction to C

C Compilation Model. Comp-206 : Introduction to Software Systems Lecture 9. Alexandre Denault Computer Science McGill University Fall 2006

Introduction. 1990s. UNSW/NICTA startup OK Labs Timeline. Operating UNSW. John Lions (19 January December 1998)

CS240: Programming in C

by Pearson Education, Inc. All Rights Reserved.

CS 240 Fall 2015 Section 004. Alvin Chao, Professor

Introduction. 1990s. UNSW/NICTA startup OK Labs Timeline. 2000s. Operating UNSW. John Lions (19 January December 1998)

Programming. Introduction to the course

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

C LANGUAGE AND ITS DIFFERENT TYPES OF FUNCTIONS

2 Compiling a C program

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

Chapter 2. Basics of Program Writing

CS 241 Data Organization. August 21, 2018

C++ Programming for Programmers using Microsoft Visual C Professional

CAAM 420 Fall 2012 Lecture 15. Roman Schutski

Introduction. 1990s. UNSW/NICTA startup OK Labs Timeline. 2000s. Operating UNSW. John Lions (19 January December 1998)

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

Chapters 1 & 2 Programming and Programs

CSCI 192 Engineering Programming 2. Subject Overview

CIS* Programming

TDDB68 Concurrent Programming and Operating Systems. Lecture 2: Introduction to C programming

COURSE OUTLINE. UNIX Programming 2014 Fall by Euiseong Seo

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

Introduction. COMP3231/9201/3891/9283 (Extended) Operating Systems Dr. Kevin Elphinstone Dr. Leonid Ryzhyk

CSCI 2132 Software Development. Lecture 2: Introduction to UNIX and Unix-like Operating Systems

CS240: Programming in C. Lecture 2: Overview

CPS1011. Program Structure {C};

Problem Set 1: Unix Commands 1

Your first C and C++ programs

Syllabus. ICS103: Computer Programming in C 2017 / 2018 First Semester (Term 171) INSTRUCTOR Office Phone Address Office Hours

DR. A.P.J. ABDUL KALAM TECHNICAL UNIVERSITY LUCKNOW. Evaluation Scheme & Syllabus. For. B.Tech. First Year (Programming for Problem Solving)

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

EL2310 Scientific Programming

Arrays and Pointers. CSC209: Software Tools and Systems Programming (Winter 2019) Furkan Alaca & Paul Vrbik. University of Toronto Mississauga

CMSC 246 Systems Programming

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

Hello, World! in C. Johann Myrkraverk Oskarsson October 23, The Quintessential Example Program 1. I Printing Text 2. II The Main Function 3

Computer Systems Lecture 9

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

Binghamton University. CS-120 Summer Introduction to C. Text: Introduction to Computer Systems : Chapters 11, 12, 14, 13

CSE 303: Concepts and Tools for Software Development

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2

C / C++ Coding Rules

CS Basics 15) Compiling a C prog.

6.S096 Lecture 1 Introduction to C

Systems Programming Advanced Software Development

Course Administration

EE 209: Programming Structures for Electrical Engineering

High Performance Computing MPI and C-Language Seminars 2009

Work relative to other classes

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

CSCI 2132: Software Development. Norbert Zeh. Faculty of Computer Science Dalhousie University. Introduction to C. Winter 2019

Programming I Laboratory - lesson 01

High Performance Computing Lecture 1. Matthew Jacob Indian Institute of Science

Computer Science 1321 Course Syllabus

Introduction to the C-Language and Programming Environment

Transcription:

COMP1917: Computing 1 1. Introduction Reading: Moffat, Chapter 1.

COMP1917 12s2 Introduction 1 Course Web Site http://www.cse.unsw.edu.au/~cs1917/12s2 Please check this Web Site regularly for updated information, including: Course Outline Notices Tutorial and Lab Exercises Assignments Style Guide Sample Programs Supplementary Material

COMP1917 12s2 Introduction 2 Textbook Recommended Text: Alistair Moffat, Programming, Problem Solving, and Abstraction with C, Pearson Educational, Australia, 2003. Reference Texts: Brian W. Kernighan and Dennis M. Ritchie, The C Programming Language, 2nd Edition, Prentice Hall, 1988. Jeri R. Hanly and Elliot B. Koffman, Problem Solving and Program Design in C, 4th Edition, Addison-Wesley, 2005. Paul Davies, The Indispensable Guide to C: With Engineering Applications, Addison-Wesley, 1995.

COMP1917 12s2 Introduction 3 Occupational Health and Safety (OHS) Computer Ergonomics for Students http://do.cse.unsw.edu.au/students/ergonomics/ergoadjust.html OHS Responsibility and accountability for students http://do.cse.unsw.edu.au/ohs

COMP1917 12s2 Introduction 4 Plagiarism ALL work submitted for assessment (including labs and assignments, etc.) must be your own work Collaborative work in the form of think tanking is encouraged, but students are not allowed to derive code together as a group during such discussions Plagiarism detection software is used on submitted work See Yellow Form: http://www.cse.unsw.edu.au/people/studentoffice/policies/yellowform.html Course Introduction, Unix Primer: http://www.cse.unsw.edu.au/help/doc/primer/node42.html CSE Addendum to UNSW Plagiarism policy: http://www.cse.unsw.edu.au/~chak/plagiarism/plagiarism-guide.html

COMP1917 12s2 Introduction 5 Planned Topics 1. Introduction 2. Numbers In, Numbers Out 3. Making Choices 4. Loops 5. Functions 6. Binary and Hexadecimal 7. Number Storage and Accuracy 8. Characters and Arrays 9. Pointers 10. Strings and Files 11. Writing a Makefile 12. Debugging 13. Structures 14. Linked Lists 15. Stacks and Queues 16. Binary Search Trees 17. Memory and Stack Frames 18. Machine Language 19. Sorting and Efficiency

COMP1917 12s2 Introduction 6 Old Lectures on YouTube Richard Buckland s COMP1917 Lectures from Session 1, 2008 are available onyoutube.com they are are not a requirement, but may be used as a supplementary resource, to see some of the topics presented from a different perspective syllabus was somewhat different, and topics were covered in a different order Search for COMP1917 UNSW

COMP1917 12s2 Introduction 7 Guiding Philosophy In this course we would like to: encourage the use of abstraction to solve problems. emphasise good documentation and coding practice. gain a general understanding of how a computer system works.

COMP1917 12s2 Introduction 8 Beyond COMP1917 This course provides you with the foundation necessary to deal with more complex concepts in: COMP1927: Computing 2 COMP2911: Engineering Design in Computing COMP2041: Software Construction COMP2121: Microprocessors and Interfacing

COMP1917 12s2 Introduction 9 Why C? good example of an imperative language widely used in industry (and science) many libraries and resources fast compilers provides low level access to machine

COMP1917 12s2 Introduction 10 Brief History of C C and UNIX share a complex history. C was originally designed for and implemented on the UNIX operating system on a PDP-11 computer. Dennis Ritchie was the author of C (around 1971). In 1973, UNIX was rewritten in C. BCPL strongly influenced the C language. B (author: Ken Thompson, 1970) was the predecessor to C, but there was no A.

COMP1917 12s2 Introduction 11 Brief History of C cont. BCPL and B were both typeless languages. C is a typed language (but not strongly). In 1983, American National Standards Institute (ANSI) established a committee to clean up and standardise the language. In 1988, the ANSI C standard was published. This greatly improved source code portability. C is the main language for writing operating systems and compilers, but it is also commonly used for a variety of applications.

COMP1917 12s2 Introduction 12 Getting Started: C Compilation one file C source code: file.c a.out (executable binary) To compilefile.c, you type the following: gcc file.c

COMP1917 12s2 Introduction 13 Getting Started: C Compilation many files C source code: file 1.c file 2.c file3.c gcc (compilation) Object files: file1.o file2.o file3.o gcc (linker) a.out (executable binary)

COMP1917 12s2 Introduction 14 Your First Program The traditional Hello World program. main( void ) { printf( "Hello, World!\n "); } Note: This example is not fully ANSI compliant.

COMP1917 12s2 Introduction 15 Compiling with gcc To compilehello.c, you type the following: gcc hello.c To run the program type:./a.out

COMP1917 12s2 Introduction 16 Command line Options with gcc The default withgcc is to compile your program uncritically, i.e. without giving you any warnings about potential problems. Good practice is to be tough on yourself: gcc -Wall hello.c The -Wall option tells gcc to report all warnings to anything it finds that is potentially wrong and non ANSI compliant. Having the compiled program ina.out is not always helpful: gcc -o hello hello.c The-o option tellsgcc to place the compiled object file in the named file rather thana.out

COMP1917 12s2 Introduction 17 Compiling with dcc Tip: if you are having trouble tracking down some nasty bugs in your code, try compiling it with dcc instead of gcc. dcc does the same job as gcc, but it does more checking for memory overlaps, etc. and will (hopefully) help you to find and fix the nasty bugs.

COMP1917 12s2 Introduction 18 Breakdown of Hello World // include standard library defs and functions #include <stdio.h> int main( void ) // function and entry point { // library call to print string constant printf( "Hello, World!\n" ); } return 0; // tell OS that no error occurred

COMP1917 12s2 Introduction 19 Key Points Functions (subroutines) can be called anything except main, which is special. main is where the program starts executing. There must be one (and only one)main Functions can have parameters (printf) or no parameters (main). Curly brackets { } are used to enclose statements in a function. A function can be called by naming it in a statement. Each statement is terminated by a semicolon ;

COMP1917 12s2 Introduction 20 Key Points cont. Comments are denoted by // or with a pair of /* and */. // comments do not extend beyond the end of line. Comments between /* and */ can span multiple lines. Example: /* This is a library function that is defined in the header file stdio.h */ printf("hello World\n"); // this calls the function

COMP1917 12s2 Introduction 21 Basic Structure of a C Program // include files // global definitions // global variables // function definitions int f( int x ) { // local variables // body of function. // main function int main( ) { // local variables // body of main function } return(... ); } return 0;.