C Programming Language Wang Jiunn Cheng 2003/07/29

Slides:



Advertisements
Similar presentations
Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
Advertisements

Senem Kumova Metin Introduction to Programming CS 115 Introduction to Computing PART I : Computer Basics PART II: Introduction to Computing/Programming.
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Introduction to C Programming
1 Lecture 2  Input-Process-Output  The Hello-world program  A Feet-to-inches program  Variables, expressions, assignments & initialization  printf()
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
Chapter 3 Program translation1 Chapt. 3 Language Translation Syntax and Semantics Translation phases Formal translation models.
Data types and variables
0 Chap. 2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations Imperative Programming, B. Hirsbrunner,
Chapter 2 Data Types, Declarations, and Displays
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Guide To UNIX Using Linux Third Edition
JavaScript, Third Edition
1 The development of modern computer systems Early electronic computers Mainframes Time sharing Microcomputers Networked computing.
String Escape Sequences
C Programming. Chapter – 1 Introduction Study Book for one month – 25% Learning rate Use Compiler for one month – 60%
CS102 Introduction to Computer Programming
A First Program Using C#
Objectives You should be able to describe: Data Types
A First Book of ANSI C Fourth Edition
PZ01A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ01A -- Introduction Programming Language Design and.
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
CNG 140 C Programming (Lecture set 9) Spring Chapter 9 Character Strings.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Programming I Introduction Introduction The only way to learn a new programming language is by writing programs in it. The first program to.
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
Chapter 3 Processing and Interactive Input. 2 Assignment  The general syntax for an assignment statement is variable = operand; The operand to the right.
CNG 140 C Programming Lecture Notes 2 Processing and Interactive Input Spring 2007.
A First Book of ANSI C Fourth Edition Chapter 3 Processing and Interactive Input.
1 Introduction Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
Input, Output, and Processing
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
Introduction to C Programming Chapter 2 : Data Input, Processing and Output.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
CNG 140 C Programming Prof. Muslim Bozyiğit Dr. Ghalib A. Shah Department of Computer Engineering Mıddle East Technical University, NCC Spring
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
CSC141 Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture - 6.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Chapter 2 Variables.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
By Mr. Muhammad Pervez Akhtar
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
C++ for Engineers and Scientists Second Edition
0 Chap.2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations 2.5Arithmetic Operators 2.6Relational.
FUNCTIONS. Midterm questions (1-10) review 1. Every line in a C program should end with a semicolon. 2. In C language lowercase letters are significant.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
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.
© 2004 Pearson Addison-Wesley. All rights reserved August 27, 2007 Primitive Data Types ComS 207: Programming I (in Java) Iowa State University, FALL 2007.
Java Programming: Guided Learning with Early Objects Chapter 1 Basic Elements of Java.
Chapter 2 Variables.
Topics Designing a Program Input, Processing, and Output
Primitive Data Types August 28, 2006 ComS 207: Programming I (in Java)
Java Programming: From Problem Analysis to Program Design, 4e
Introduction to C++ Programming
Chapter 2: Basic Elements of Java
A First Book of ANSI C Fourth Edition
Introduction to Computer Programming
Topics Designing a Program Input, Processing, and Output
강의 내용 및 방법 접근방법 리포트 시험 Lambda Calculus, Proof of Correctness
Topics Designing a Program Input, Processing, and Output
Chapter 2 Variables.
DATA TYPES There are four basic data types associated with variables:
Introduction to C Programming
Presentation transcript:

C Programming Language Wang Jiunn Cheng 2003/07/29

References Brian W. Kernighan and Dennis M. Ritchie, The C Programming Language, 2/e, Prentice Hall. Alice E. Fischer, David W. Eggert, Stephen M. Ross, Applied C: An Introduction and More, McGraw-Hill. Stephen Prata, C Primer Plus, 4/e, Sams.

Table of Contents Introduction A Tutorial Introduction Types, Operators, and Expressions Control Flow Functions and Program Structure Pointers and Arrays Structures Input and Output The UNIX System Interface

Introduction Historical Background of Languages –In 1957, IBM 704 and FORTRAN (the first compiled high-level imperative language)… –In 1958, MIT AI project and LISP (the first functional programming language)… –In 1958, ALGOL (the greatest influence algorithmic language)… –In 1960, COBOL (the most and oldest widely used language in business computing)… –In 1964, BASIC (the easiest language for beginners to learn and the most popular language on microcomputer)… –In 1970, PASCAL (the widely used as a teaching language)… –In 1972, UNIX and C (the most portable system language)… –In 1972, AI and Prolog (a nonprocedural logic programming language)… –In 1980, Smalltalk (the first object-oriented language)… –In 1983, DoD and Ada (the largest design effort language)… –In 1986, C++ (the combining imperative and object-oriented language)… –In 1990, Java (the simplest object-oriented language)…

Introduction Historical Background of Computers –The first generation (1946~1954)(the vacuum-tube era) In 1944, IBM Mark I (the first electromechanical computer)… In 1946, ENIAC (the first programmable electronic computer)… In 1951, UNIVAC (correctly predicts election of US president)… John von Neumann and EDVAC (the first stored-program computer)… MIT Whirlwind I (the first computer with a ferrite-core memory)… –The second Generation (1955~1964)(the transistor era) IBM 7094 (the very successfully transistorized commercial computer)… ALGOL, COBOL, and FORTRAN… main memories were replaced by ferrite cores and magnetic drums… switching circuits were replaced by transistors…

Introduction Historical Background of Computers (continued) –The third generation (1965~1974)(the IC era) transistor circuits were replaced by integrated circuits… ferrite-core main memories were replaced by semiconductor memories… microprogramming technique was widely used in CPU design… IBM 360 series (mainframe computer of industry standard)… CDC 6600, 7600, and Cyber series… ILLIAC IV (a notable supercomputer)… DEC PDP-5, PDP-8 series (the first commercial minicomputer)… –The fourth generation (1975~)(the VLSI era) microporcessors and microcomputers… In 1975, MIT Altair 8800 (the first microcomputer)… In 1977, APPLE II (the first well-known personal computer)… In 1981, IBM PC series… Motorola 6800 and series… Intel 8086/286/386 families… Intel iPSC (the first personal supercomputer)…

Introduction K & R A general-purpose programming language A relatively low level language A system programming language A machine-independent programming language A portable programming language Closely associated with UNIX system

How to conceive a program? thinking compiling linking Get a problem assigned by teachers or clients Conceive a solution or algorithm to solve this problem editing coding Write C programs of this task xxx.c xxx.cpp Verify source programs via C compiler Prune syntax or semantic errors xxx.o xxx.obj Correct the program logic reporting Print out the correct results Work complete! Create an executable program xxx xxx.exe Blue for UNIX Black for MS Windows running debugging Test program with data

Programming Studio Hello program –#include line –main() function –printf() function Fahrenheit-celsius conversion program –integer variables –arithmetic expressions –while loop –formatted printf()

Programming Studio (cont’d) The second version of conversion program –floating point variables –for loop The third version of conversion program –#define line File coping program –getchar() function –putchar() function –EOF constant –precedence and association of operators

Programming Studio (cont’d) Character counting program –prefix and postfix operators –overflow of integer variables –null statement Line counting program –if statement –== operator –character constant –ASCII character –newline character

Programming Studio (cont’d) Word counting program –if-else statement –|| operator Character occurrence counting program –integer array –consecutive increasing values of ASCII characters –multi-way decision of if-else statement

Programming Studio (cont’d) Power function program –power() function –arguments of function –return value of function –function prototype –call by value Finding the longest line program –character array –multiple functions –null character –void return type

Programming Studio (cont’d) The second version of finding program –external variable –extern declaration –multiple files

The first problem Write a program to print the following words on your console. “Trust me! You can make it! %? #include main() { printf(“Trust me! You can make it! %? }

Tokens stdio.h main printf <# { ; } include> () ( ) “Trust me! You can make it! %?

Typing Skill on Your Keyboard ASDF vs. JKL;

Vocabulary (1:~) Blue for C Programming Terminology Black for Vocabulary Chapter 1: (cont’d) –Approach –Drawback –Extrapolate –Framework –Tutorial –Concise –Precise –Elegant 1.1 –Hurdle –Leap –Text –Mechanical –Compile –Operating system –File –Botch –Omit –Character –Misspell 1.1 (cont’d) –Executable –Statement –Store –Subroutine –Procedure –Perform –Appendix –Communicate –List –Argument –Parentheses –Braces –String –Quote –Sequence –Notation 1.1 (cont’d) –Newline –Margin –Error message –Automatically –Identical –Escape sequence –Extensible –Mechanism –Invisible –Tab –Backspace –Double quote –Backslash Chapter 1: –Essential –Language –Program –Bog –Precise –Concentrate –Variable –Constant –Arithmetic –Control flow –Function –Rudiment –Intentionally –Exception –Point –Structure –Operator –Statement –Standard –Library

Vocabulary (1.2) 1.2 –Expression –Formula –Temperature –Equivalent –Comment –Declaration –Loop –Formatted output –Briefly –Ignore –Blank –Announce –Property –Type –Integer –Floating point –Fractional part –Bit –Quantity 1.2 (cont’d) –Significant –Digit –Magnitude –Byte –Double-precision –Object –Array –Structure –Union –Pointer –Assignment –Conversion –Initial –Individual –Semicolon –Indent –Glance –Emphasize –Critical –Recommend 1.2 (cont’d) –Passionate –Consistently –Multiply –Divide –Division –Truncate –Discard –Normally –Accessible –Behavior –Conform –Concentrate –Defer –Right-justified –Accurate –Version –Decimal point –Formula –Operand –Explicit 1.2 (cont’d) –Width –Specification –Octal –Hexadecimal –Elimination –Limit –Construction –Context 1.3 –Permissible –Complicated –Evaluate –Initialization –Condition –Increment –Arbitrary –Appropriate –Compact –Reverse

Vocabulary (1.4~) 1.4 –Observation –Convey –Symbolic –Replacement –Conventionally –Distinguish 1.5 –Prototype –Model –Stream –Responsibility –Conform –Keyboard –Screen –Interleaved –Relational operator –Bit pattern –Subtle –Valid –Solution –Distinctive –Confused –End of file –Signal –Centralize –Shrink –Idiom –Style –Impenetrable –Curb –Precedence –Absence –Encounter –Count –Decrement –Prefix –Postfix –Accumulate –Overflow –Cope –Suppress –Grammatical –Isolate –Null statement –Separate –Intelligently –Boundary –Mention –Caution –Occasionally –Legal –Warning –Obvious –Topic –Unambiguous –Bare-bone –Literal –Tiny –Clarity –Associate –Guarantee –Truth –Falsehood –Alternative

Vocabulary (1.6~) 1.6 –Artificial –Illustrate –Aspect –Category –Subscript –Consecutive –Frequently –Advisable –Branch –Histogram –Bar –Horizontal –Vertical –Orientation –Challenge 1.7 –Encapsulate –Implementation –Exponentiation –Conflict –Return –Environment –Erroneous –Prototype –Parameter –Optional –Documentation –Syntax 1.8 –Pass –Reference –Temporary –Asset –Liability –Extraneous 1.9 –Manipulate –Fetch –Sticky –Limit –Brevity –Issue –Revise –Trailing blanks –Remove 1.10 –Automatic –Invocation –Garbage –External –Globally –Permanently –Storage –Concrete –Allocate –Syntactically –Circumstance –Destroy –Core –Pause –Complexity