Spring 2018 NENG 202 Introduction to Computer Programming

Similar documents
CMSC 246 Systems Programming

PROGRAMMAZIONE I A.A. 2017/2018

EL2310 Scientific Programming

by Pearson Education, Inc. All Rights Reserved.

CS120 Computer Science I. Instructor: Jia Song

Fundamentals of Programming. Lecture 1: Introduction to C Programming

CS 113: Introduction to

Introduction to Basis and Practice in Programming

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

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

COMP1917: Computing 1 1. Introduction

EL2310 Scientific Programming

INTRODUCTION TO THE COURSE

CS Prof J.P.Morrison

COMP1917: Computing 1 1. Introduction

Introduction to C Programming (Part A) Copyright 2008 W. W. Norton & Company. All rights Reserved

Your first C and C++ programs

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

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

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

CS 50 Introduction to Computer Science I

COP 3275: Chapter 02. Jonathan C.L. Liu, Ph.D. CISE Department University of Florida, USA

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

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

Administration Computers Software Algorithms Programming Languages

Introduction to Computing Lecture 01: Introduction to C

CS 211 Programming I for Engineers

Fundamentals of Programming (C)

Programming. Dr Ben Dudson University of York

COSC 2P95. Introduction. Week 1. Brock University. Brock University (Week 1) Introduction 1 / 18

MA400: Financial Mathematics

Programming in C and C++

C Fundamentals & Formatted Input/Output. adopted from KNK C Programming : A Modern Approach

C LANGUAGE AND ITS DIFFERENT TYPES OF FUNCTIONS

CS 240 Fall 2015 Section 004. Alvin Chao, Professor

LECTURE/ STUDY NOTES ON C

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

Course Information and Introduction

C PROGRAMMING THE C PROGRAMMING THE PDF C PROGRAMMING TUTORIAL IN PDF - CURRENT AFFAIRS 2018 C (PROGRAMMING LANGUAGE) - WIKIPEDIA

Welcome to... CS113: Introduction to C

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

CSI33 Data Structures

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

Week 2 C Fundamentals; Formatted Input/Output; int and float Types

Announcements. CSCI 334: Principles of Programming Languages. Lecture 18: C/C++ Announcements. Announcements. Instructor: Dan Barowy

C Fundamentals & Formatted Input/Output. adopted from KNK C Programming : A Modern Approach

The C Programming Language

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

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

Welcome to CS 106L! Ali Malik

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

CSE 303 Lecture 8. Intro to C programming

Introduction to Programming

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

Chapter 1: Introduction

Appendix to Topic IV

Programming Languages: Part 1. Robert M. Dondero, Ph.D. Princeton University

CS201 - Lecture 1 The C Programming Language

COMP322 - Introduction to C++ Lecture 01 - Introduction

Chapter 1 & 2 Introduction to C Language

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

EE 209: Programming Structures for Electrical Engineering

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

EECS2031 Software Tools

Syllabus of ENPM 691: Secure Programming in C

EP241 Computer Programming

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

Programming in C UVic SEng 265

Compiling Techniques

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

Chapters 1 & 2 Programming and Programs

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

CNG 140 C Programming. Syllabus. Course Info Fall Semester. Catalog Description

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

EE 209: Programming Structures for Electrical Engineering. (Many Slides Borrowed from Princeton COS 217)

Fall, $ cat welcome.c #include <stdio.h>

6.S096 Lecture 1 Introduction to C

Chapter 1 Introduction to Computers and C++ Programming

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

The C Programming Language

Programming and Data Structure

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

Introduction to the C-Language and Programming Environment

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

Programming for Engineers: Getting Started

Introduction to C++ Introduction to C++ 1

Unix to Linux. CS 3113 Fall 2018 Dr. Christan Grant

Tools of the Trade The C Language Laboration 04. Outline. 1 Tools of the Trade. 2 The C Language. 3 Laboration 04

Scientific Computing

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

Compilers for Modern Architectures Course Syllabus, Spring 2015

Introduction. A. Bellaachia Page: 1

C Programming for Engineers Introduction

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

Outline. 1 About the course

CS 241 Data Organization. August 21, 2018

Object-Oriented Programming CSCI-UA

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

Advanced Programming Concepts. CIS 15 : Spring 2007

Transcription:

Spring 2018 NENG 202 Introduction to Computer Programming Introductory programming course based on the C language Course Website: http://www.albany.edu/~yx152122/neng202-18.html Instructor: Prof. Y. Alex Xue Expertise: Theoretical and Computational Nanoscience Office: CESTM B230C Office Hour: Friday 3-4PM E-mail: yxue@sunypoly.edu Grading Two in-semester exams (16 points each). One final take-home programming project (28 points) Eight programming projects (5 points each) Check assignment due date on the course website Discussion encouraged but work independently please! Required Text K.N. King, C Programming: A Modern Introduction, 2 nd Edition (W.W. Norton & Company, 2008) Ch. 21-Ch. 27 contain reference materials on C standard library. Further materials on C programming can be found at the course website

Weekly Course Topics Part I Formatted Input/Output Operators and Expressions Selection/Looping Statements Part II Basic Data Types 1-D Array Functions and Program Organization Part III Pointers Pointers and Arrays Strings, Complex Numbers

Week 1 Introducing C Introducing Computer Programming Programming and Programming Language History of C Strength and Weakness of C Your First C Program Writing, Compiling and Linking Cygwin/gcc/notepad++

Computer Programming and Programming Language Computer programming is a process that leads from an original formulation of a computing problem to executable programs. It involves activities such as analysis, understanding, and generically solving such problems resulting in an algorithm,, implementation (or coding) of the algorithm in a target programming language, The algorithm is often only represented in human-parsable form and reasoned about using logic. Source code is written in one or more programming languages. The purpose of programming is to find a sequence of instructions that will automate performing a specific task or solve a given problem. A programming language is an artificial language designed to communicate instructions to a machine

Programming Languages

Programming Languages Popularity: 2010

Programming Languages Popularity (IEEE Spectrum) 2015 2014

Origins of C C is a by-product of UNIX, developed at Bell Laboratories by Ken Thompson, Dennis Ritchie, and others. Thompson designed a small language named B. B was based on BCPL, a systems programming language developed in the mid-1960s, which in turn was based on Algol. By 1971, Ritchie began to develop an extended version of B. He called his language NB ( New B ) at first. As the language developed further, he changed its name to C. The language was stable enough by 1973 that UNIX could be rewritten in C.

Standardization of C K&R C Described in Kernighan and Ritchie, The C Programming Language (1978) De facto industry standard C89/C90 ANSI standard X3.159-1989 (completed in 1988; formally approved in December 1989) International standard ISO/IEC 9899:1990 C99 International standard ISO/IEC 9899:1999 Incorporates changes from Amendment 1 (1995)

C-Based Programming Languages C++ (invented by Bjarne Stroustrup at Bell Lab, 1979- ) includes all the features of C, but adds classes, templates and other features to support object-oriented and generic programming features. Java is based on C++ and therefore inherits many C features. C# is a more recent language derived from C++ and Java. Python is a high-level language that is implemented using C. MATLAB, originally based on FORTRAN, is implemented in C

Strengths of C Efficiency Portability Relatively small language Low-level constructs

Weaknesses of C Programs can be error-prone. Programs can be difficult to understand. Programs can be difficult to modify. Think about Programming Languages vs. Natural Languages vs. Mathematics Context Grammar/Rule Style

Effective Uses of C Adopt a sensible set of coding conventions. Avoid tricks and overly complex code. Stick to the standard. Learn how to avoid pitfalls.

Hello, World! : Your First C Program #include <stdio.h> int main(void) { printf("to C, or not to C: that is the question.\n"); return 0; } This program might be stored in a file named pun.c. The file name doesn t matter, but the.c extension is often required.

Compiling and Linking Before a program can be executed, three steps are usually necessary: Preprocessing. The preprocessor obeys commands that begin with # (known as directives) Compiling. A compiler translates then translates the program into machine instructions (object code). Linking. A linker combines the object code produced by the compiler with any additional code needed to yield a complete executable program. The preprocessor is usually integrated with the compiler.

Compiling and Linking with gcc gcc is the GNU Project C compiler A command-line program gcc takes C source files as input To compile and link the pun.c program under UNIX, enter the following command in a terminal or command-line window: % gcc pun.c Outputs an executable by default: a.exe Linking is automatic when using gcc; no separate link command is necessary.

Compiling and Linking with gcc To compile with a different executable output name simply type: % gcc -o pun pun.c -std=c99 -Wall All gcc options are prefixed with hyphen -! -o option tells the compiler to name the executable pun -Wall tells it to print out all relevant warnings (very useful!!!) To execute the program in cygwin, simply type: %./pun.exe

Compiling and Linking Before a program can be executed, three steps are usually necessary: Preprocessing. The preprocessor obeys commands that begin with # (known as directives) Compiling. A compiler translates then translates the program into machine instructions (object code). Linking. A linker combines the object code produced by the compiler with any additional code needed to yield a complete executable program. The preprocessor is usually integrated with the compiler. Preprocessing, Compiling and Linking are integrated when using gcc $ gcc -o pun pun.c -O -Wall -std=c99 $./pun.exe

General Form of a Simple C Program Simple C programs have the form directives C uses { and } in much the same way that some other languages use words like begin and end. int main(void) { statements } Even the simplest C programs rely on three key language features: Directives Functions Statements #include <stdio.h> int main(void) { printf("to C, or not to C: that is the question.\n"); return 0; }