IntroductionCS-2301 D-term 20091 CS-2301 System Programming for Non-Majors Professor Hugh C. Lauer D-term 2009 (Slides include materials from The C Programming.

Slides:



Advertisements
Similar presentations
IntroductionCS-4513, D-Term Distributed Computing Systems Hugh C. Lauer Adjunct Professor (Slides include materials from Operating System Concepts,
Advertisements

C Programming for engineers Teaching assistant: Ben Sandbank Home page:
Introduction to Computer Programming I CSE 113
Functions and InterfacesCS-2303, C-Term Functions and Interfaces in C CS-2303, System Programming Concepts (Slides include materials from The C Programming.
IntroductionCS-4513 D-term Introduction CS-4513 Distributed Computing Systems (Slides include materials from Operating System Concepts, 7 th ed.,
1 CSSE 332 Course Introduction. Roll Call and Introductions Name (nickname) Name (nickname) Hometown Hometown Local Residence Local Residence Major Major.
Programming The Development Environment and Your First C Program.
Unix Continuum of Tools Do something once: use the command line Do something many times: –Use an alias –Use a shell script Do something that is complex.
Course Information 1 CS502 Spring 2006 Operating Systems CS502 Spring 2006 Mondays – 6PM.
OBJECT ORIENTED PROGRAMMING I LECTURE 1 GEORGE KOUTSOGIANNAKIS
IntroductionCS-2301, B-Term CS-2301, System Programming for Non-Majors (Slides include materials from The C Programming Language, 2 nd edition, by.
CS 153: Concepts of Compiler Design August 25 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
CSE : Programming in C Instructor: Lei Wang Office: Dreese Lab 474 Office Hour: Friday.
1 Are you ready?. 2 Professor: Vladimir Misic Office : Phone: Office Hours : Mon, Tue; 2:00pm – 4:00pm Website :
COP4020/CGS5426 Programming languages Syllabus. Instructor Xin Yuan Office: 168 LOV Office hours: T, H 10:00am – 11:30am Class website:
CS 11 C track: lecture 1 Preliminaries Need a CS cluster account cgi-bin/sysadmin/account_request.cgi Need to know UNIX ITS.
Programming Design Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
Welcome to CS 3260 Dennis A. Fairclough. Overview Course Canvas Web Site Course Materials Lab Assignments Homework Grading Exams Withdrawing from Class.
Gator Engineering 1 Chapter 2 C Fundamentals Copyright © 2008 W. W. Norton & Company. All rights reserved.
CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann.
Instructor: Tina Tian. About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or .
1 Agenda Administration Background Our first C program Working environment Exercise Memory and Variables.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 13: An Introduction to C++
Programming With C.
1 計算機程式設計 Introduction to Computer Programming Lecture01: Introduction and Hello World 9/10/2012 Slides modified from Yin Lou, Cornell CS2022: Introduction.
IntroductionCS-2301 B-term CS-2301, System Programming for Non-majors Hugh C. Lauer Adjunct Professor (Slides include materials from The C Programming.
CS 140 Computer Programming (I) Second semester (3 credits) Imam Mohammad bin Saud Islamic University College of Computer Science and Information.
Welcome to CS 115! Introduction to Programming. Class URL Write this down!
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
Course Information Sarah Diesburg Operating Systems COP 4610.
Course Information Andy Wang Operating Systems COP 4610 / CGS 5765.
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.
CSE 1105 Week 1 CSE 1105 Introduction to Computer Science & Engineering Time: Wed 4:00 – 4:50 Thurs 9:30 – 10:20 Thurs 4:00 – 4:50 Place: 100 Nedderman.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Department of Electronic & Electrical Engineering Introduction to C - The Development cycle. Why C? The development cycle. Using Visual Studio ? A simple.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Elements of Computing Science I Course Web Site: The lecture outlines.
Computer Networks CNT5106C
Course Information CSE 2031 Fall Instructor U. T. Nguyen /new-yen/ Office: CSEB Office hours:  Tuesday,
An overview of C Language. Overview of C C language is a general purpose and structured programming language developed by 'Dennis Ritchie' at AT &T's.
Course Information CSE 2031 Fall Instructor U.T. Nguyen Office: CSE Home page:
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
Chapter 1 slides1 What is C? A high-level language that is extremely useful for engineering computations. A computer language that has endured for almost.
CSE-102: PROGRAMMING FUNDAMENTALS LECTURE 3: BASICS OF C Course Instructor: Syed Monowar Hossain 1.
Course Information EECS 2031 Fall Instructor Uyen Trang (U.T.) Nguyen Office: LAS Office hours: 
Introduction to C Topics Compilation Using the gcc Compiler
UMBC CMSC 104 – Section 01, Fall 2016
Course Information EECS 2031 – Section A Fall 2017.
Computer Programming (CS-161)
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Course Information Mark Stanovich Principles of Operating Systems
Welcome to CS 1010! Algorithmic Problem Solving.
Andy Wang Operating Systems COP 4610 / CGS 5765
Welcome to CS 1010! Algorithmic Problem Solving.
Andy Wang Operating Systems COP 4610 / CGS 5765
Andy Wang Operating Systems COP 4610 / CGS 5765
CS-2303 System Programming Concepts
History and Background
Accelerated Introduction to Computer Science
Your first C and C++ programs
Course Information EECS 2031 Fall 2016.
Andy Wang Operating Systems COP 4610 / CGS 5765
ECE 103 Engineering Programming Chapter 1 Introduction
EECE.2160 ECE Application Programming
CS-2303 Introduction (continued)
Andy Wang Operating Systems COP 4610 / CGS 5765
Loose ends from yesterday
CS201 – Course Expectations
Presentation transcript:

IntroductionCS-2301 D-term CS-2301 System Programming for Non-Majors Professor Hugh C. Lauer D-term 2009 (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie and from C: How to Program, 5 th and 6 th editions, by Deitel and Deitel)

IntroductionCS-2301 D-term Course Objectives C language programming Designing, implementing, debugging, etc. How the hardware executes C programs … and other kinds of programs Preparation for computational challenges of engineering, scientific, and other professions Preparation for upper-level courses in computing “Thinking computationally”

IntroductionCS-2301 D-term Why? Computing and Programming: a life skill for all technical professionals Thinking Computationally: organizing your engineering/scientific/technical thoughts to be amenable to computational solutions

IntroductionCS-2301 D-term Why C? Because we have to! Many situations outside of CS where it is only language or system available Small, embedded systems, instrumentation, etc. Many “low-level” situations that don’t have support for “high-level” languages Operating systems, real-time systems, drivers

IntroductionCS-2301 D-term Why not C? C is very low-level Data structures must be programmed “by hand” Operations must be done out in “long hand” No support for “object oriented” design Marginal support for higher-level thought processes Better alternatives available for technical applications Verilog, VHDL, System C – semiconductor design Matlab, SimuLink – physical modeling LabView – instrumentation and control Excel – accounting and statistics SQL – billing and transactions …

IntroductionCS-2301 D-term This Course Lectures C programming language, syntax, semantics, etc. Common data structures that technical professionals are likely to need or encounter in C Programming Assignments Write programs to exercise various language constructs and data structures Mandatory for passing this course Lab Sessions How to use the system, tools, debuggers, etc. Practical help from TAs, etc.

IntroductionCS-2301 D-term This Course (continued) Tuesdays & Fridays, 8:00–9:50 AM Fuller 320 Weekly Lab Sessions D01 – Kaven 202, Wednesdays 2:00-2:50 PM D02 – Kaven 202, Wednesdays 3:00-3:50 PM D03 – Kaven 202, Wednesdays 4:00-4:50 PM Three exams (one hour each) April 3 April 17 May 5 Review session prior to exam on same day Closed book, one 8½-by-11 sheet of prepared notes, no calculators or electronics

IntroductionCS-2301 D-term Prerequisites CS-1101 or CS-1102 Or other “first” programming course Or programming job, or other experience Background survey Note: credit may not be earned for both CS and CS-2303

IntroductionCS-2301 D-term Logistics Course web site – Professor’s office Hours –Tuesdays and Fridays, 10:00-11:00 AM, or by appointment (additional hours TBD) –Fuller 137:– (508) Contacts cs.wpi.edu Class lists –cs2301-all or same domain Teaching assistants –Rabin Karki (TA) –Jeff Zhou (TA) –Brian Bates (SA)

IntroductionCS-2301 D-term Required Textbook The C Programming Language, 2 nd edition, by Brian Kernighan and Dennis Ritchie, Prentice Hall, 1988 Bring to all classes and all lab sessions

IntroductionCS-2301 D-term Textbook Outline Chapter 1: a tutorial aimed at people who already know how to program Chapters 2-8: description of C language Slightly different order from Chapter 1 Appendix A: the C language reference Official definition of language is here! Appendix B: the standard libraries You will use these a lot!

IntroductionCS-2301 D-term Ground Rule #1 There are no “stupid” questions. It is a waste of your time and the class’s time to proceed when you don’t understand the basic terms. If you don’t understand it, someone else probably doesn’t it, either.

IntroductionCS-2301 D-term Ground Rule #2 Help each other! Even when a project or assignment is specified as individual, ask your friends or classmates about stuff you don’t understand. It is a waste of your time try to figure out some obscure detail on your own when there are lots of resources around. When you have the answer, write it in your own words (or own coding style).

IntroductionCS-2301 D-term Names and Faces It is in your own interest that I know who you are. Students who speak up in class usually get more favorable grades than those who don’t When speaking in class, please identify yourselves

IntroductionCS-2301 D-term WPI Academic Honesty Policy It is a violation of the WPI Academic Honesty Policy to submit someone else’s work as your own. It is not a violation of WPI’s Academic Honesty Policy to ask for help! Classmates, TAs, friends, mentors, … Explanations of things you don’t understand

IntroductionCS-2301 D-term Additional Help Academic Resource Center has Tutors available to assist in CS The schedule is posted and copies are available on the door of the M*A*S*H room and Tutor Center, Daniels Hall, 1 st floor.

IntroductionCS-2301 D-term Instructor — Hugh C. Lauer Affiliated Associate Professor Ph. D. Carnegie-Mellon, –Dissertation “Correctness in Operating Systems” Lecturer: University of Newcastle upon Tyne, UK Approximately 30 years in industry in USA Research topics –Operating Systems –Proofs of Correctness –Computer Architecture –Networks and Distributed Computing –Real-time networking –3D Volume Rendering –Surgical Simulation and Navigation –…

IntroductionCS-2301 D-term Systems and Programming Experience IBM Corporation University of Newcastle Systems Development Corporation Xerox Corporation (Palo Alto) Software Arts, Inc. Apollo Computer Eastman Kodak Company Mitsubishi Electric Research Labs (MERL) Real-Time Visualization Founded and spun out from MERL Acquired by TeraRecon, Inc. SensAble Technologies, Inc. Dimensions Imaging, Inc. (new start-up)

IntroductionCS-2301 D-term Experience (continued) CTO, Chief Architect of VolumePro™ 1000 World’s first interactive 3D rendering engine for CT, MRI, seismic scans for PC-class computers 7.5-million gate, high-performance ASIC 10 9 illuminated graphical samples per second Two seminal contributions to computer science Duality hypothesis for operating systems (w/Roger Needham) First realization of opaque types in type-safe languages (with Edwin Satterthwaite) 21 US patents issued Computer architecture Software reliability Networks Computer graphics & volume rendering

IntroductionCS-2301 D-term My Other Job System for detecting positions of surgical instruments relative to patients’ bodies Embedded, real-time system Detect phase angles from transmitted microwaves Convert into positions and orientations of objects Programmed in LabView A graphical, object-oriented, data-flow language

IntroductionCS-2301 D-term Questions?

IntroductionCS-2301 D-term The C Language First created to develop Unix – late 1960s Kernighan & Ritchie, 1 st edition – 1978 ANSI C – 1988 Kernighan & Ritchie, 2 nd edition, 1988 Implemented by nearly all C compilers C95, C99 Minor additions (to be noted as we get to them) Most major C compilers

IntroductionCS-2301 D-term Successors to C C++ Developed by Bjarne Stroustrup at Bell Labs Major extension of C to support object-oriented programming Attempted to preserve syntax and structure of C Java Rewrite of C++ at Sun Microsystems Machine independence, portability Ability to embed in web pages Huge libraries of packages for all kinds of stuff

IntroductionCS-2301 D-term Your First C Program #include int main () { printf(″Hello, World!\n″); return 0; }

IntroductionCS-2301 D-term Fundamental Rule in C Every identifier must be declared before it can be used in a program Definition:– “identifier” A sequence of letters, digits, and ‘_’ Must begin with a letter or ‘_’ Case is significant –Upper and lower case letters are different Must not be a “reserved word” — see p. 192 Definition:– “declare” Introduce an identifier and the kind of entity it refers to Optionally, define associated memory or program

IntroductionCS-2301 D-term So where is printf declared? #include int main () { printf(″Hello, World!\n″); return 0; }

IntroductionCS-2301 D-term So where is printf declared? #include int main () { printf(″Hello, World!\n″); return 0; } Answer: in this file!

IntroductionCS-2301 D-term Your First C Program #include int main () { printf(″Hello, World!\n″); return 0; } A header file Contains declarations of names, functions, data, of things defined elsewhere E.g., by the system Text of the header file is inserted by compiler into your program As if you wrote it yourself!

IntroductionCS-2301 D-term Your First C Program #include int main () { printf(″Hello, World!\n″); return 0; } A function declaration Declares the name and defines the body of your function May take arguments, returns an integer main is a special name to the system The place where a program “starts”

IntroductionCS-2301 D-term Your First C Program #include int main () { printf(″Hello, World!\n″); return 0; } Body of the function Defines what the function “does” Sequence of statements Each does a step of the function Enclosed in curly brackets { }

IntroductionCS-2301 D-term Your First C Program #include int main () { printf(″Hello, World!\n″); return 0; } Call to another function In this case, a function defined by the system Prints some data on standard output

IntroductionCS-2301 D-term Your First C Program #include int main () { printf(″Hello, World!\n″); return 0; } Argument to printf – a constant string Enclosed in straight double quotes Note the new-line character ′\n′ at the end

IntroductionCS-2301 D-term Your First C Program #include int main () { printf(″Hello, World!\n″); return 0; } A return statement return is a reserved word in C main should return zero if no error; non-zero if error

IntroductionCS-2301 D-term Your First C Program #include int main () { printf(″Hello, World!\n″); return 0; } Note that statements typically end with semicolons So compiler can tell where end of statement is

IntroductionCS-2301 D-term Questions? Write, compile, and execute this program in Lab session tomorrow

IntroductionCS-2301 D-term What happens to your program … …after it is compiled, but before it can be run?

IntroductionCS-2301 D-term Example #include int main () { printf (″Hello, world\n″); } Symbol defined in your program and used elsewhere main Symbol defined elsewhere and used by your program printf

IntroductionCS-2301 D-term Static Linking and Loading Printf.c Printf.o Library gcc ar Linker Memory HelloWorld.c gcc HelloWorld.o Loader a.out (or name of your command)

IntroductionCS-2301 D-term Compiling Your Program gcc HelloWorld.c Compiles the program in HelloWorld.c, links with any standard libraries, puts executable in a.out You should find HelloWorld.o in your directory gcc –o hello_world HelloWorld.c Same as above, but names the executable file hello_world instead of a.out gcc –lrt HelloWorld.c Searches library named rt.a for functions to link (in addition to standard libraries)

IntroductionCS-2301 D-term Compiling Your Program (continued) gcc foo.c bar.c help.c Compiles the programs foo.c, bar.c, and help.c, links with standard libraries, executable in a.out You should find foo.o, bar.o, and help.o in your directory gcc –o Lab2 foo.c bar.c help.c Same as above, but names the executable file Lab2 gcc –c foo.c bar.c help.c Compiles foo.c, bar.c, and help.c to foo.o, bar.o, and help.o but does not link together

IntroductionCS-2301 D-term Questions?

IntroductionCS-2301 D-term Short Break Please fill out survey questionnaire