CSE 495.21: Programming in C Instructor: Lei Wang Office: Dreese Lab 474 Office Hour: Friday.

Slides:



Advertisements
Similar presentations
CSE 105 Structured Programming Language (C)
Advertisements

Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
Senem Kumova Metin // FALL CS115 Introduction to Programming Inst. Senem Kumova Metin Textbook : A Book on C, A. Kelly.
Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
C Programming for engineers Teaching assistant: Ben Sandbank Home page:
CIS 101: Computer Programming and Problem Solving Lecture 8 Usman Roshan Department of Computer Science NJIT.
Introduction to C Programming CE Lecture 1 Introduction to C.
CSE1301 Computer Programming Lecture 4: C Primitives I.
Three types of computer languages
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.
If You Missed Last Week Go to Click on Syllabus, review lecture 01 notes, course schedule Contact your TA ( on website) Schedule.
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?
Introduction to C Programming Overview of C Hello World program Unix environment C programming basics.
1 CSE 303 Lecture 8 Intro to C programming read C Reference Manual pp. Ch. 1, , 2.6, 3.1, 5.1, , , , Ch. 8 ; Programming.
Guide To UNIX Using Linux Third Edition
COMP1170 Midterm Preparation (March 17 th 2009) Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education.
C programming Language and Data Structure For DIT Students.
Introduction to C. A Brief History Created by Dennis Ritchie at AT&T Labs in 1972 Originally created to design and support the Unix operating system.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Computer Science 210 Computer Organization Introduction to C.
1 CS 240 Programming in C and UNIX Lecturer: Bob Wilson Office: S Phone:
CS 11 C track: lecture 1 Preliminaries Need a CS cluster account cgi-bin/sysadmin/account_request.cgi Need to know UNIX ITS.
CS140: Intro to CS An Overview of Programming in C by Erin Chambers.
Introduction to C Programming. A Brief History u Created by Dennis Ritchie at AT&T Labs in 1972 u Originally created to design and support the Unix operating.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
Instructor: Tina Tian. About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or .
CSE 2541 – Advanced C Programming Instructor: Yang Zhang
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.
Review C Language Features –control flow –C operators –program structure –data types –I/O and files Problem Solving Abilities.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
CSE 2541 – Advanced C Programming. Course info Prereq – CSE 2221 or CSE 222 Co-req – CSE 2231 Website
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
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.
OO Data Structures SE Dr. Samir Tartir 2010/2011 Second Semester.
The Software Construction Process. Computer System Components Central Processing Unit (Microprocessor)
C++ / G4MICE Course Session 1 - Introduction Edit text files in a UNIX environment. Use the g++ compiler to compile a single C++ file. Understand the C++
C LANGUAGE Characteristics of C · Small size
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
First Compilation Rudra Dutta CSC Spring 2007, Section 001.
CISC105 – General Computer Science Class 4 – 06/14/2006.
Introduction to C Programming Language. History of C  C was evolved by Dennis Ritchie at AT&T Bell Laboratories in early of 1970s  Successor of: ALGOL.
C Part 1 Computer Organization I 1 August 2009 © McQuain, Feng & Ribbens A History Lesson Development of language by Dennis Ritchie at Bell.
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.
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
小型系統 心情 vs. 古典樂 心情 vs. 古典樂 浪漫求籤系統 美食導航系統 季潔亭雅鈺熒岱芸 美食導航系統 楊氏音樂模擬大會考人瑋 若維 芷萱 伽倩 楊氏音樂模擬大會考 麥當勞熱量計算系統 火星文困擾你嗎 ? 火星文困擾你嗎 ? 歌詞知多少 - 挑戰你的腦容量英琪 日馨 青雪 鈺娟.
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
Lecture 3 Translation.
Computer Science 210 Computer Organization
C Programming Hardik H. Maheta.
C Language By Sra Sontisirikit
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.
C Basics.
Introduction to C Programming Language
B. Ramamurthy University at Buffalo
CS190/295 Programming in Python for Life Sciences: Lecture 1
Computer Science 210 Computer Organization
B. Ramamurthy University at Buffalo
B. Ramamurthy University at Buffalo
B. Ramamurthy University at Buffalo
Govt. Polytechnic,Dhangar
Introduction to C Topics Compilation Using the gcc Compiler
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
B. Ramamurthy University at Buffalo
2008/09/29: Lecture 7 CMSC 104, Section 0101 John Y. Park
Introduction to C Topics Compilation Using the gcc Compiler
Computer Science Department
Presentation transcript:

CSE : Programming in C Instructor: Lei Wang Office: Dreese Lab 474 Office Hour: Friday 4:00--5:00PM

Course Information: Course Page: state.edu/~wangle/courses/459.21sp12/index.html Prerequisite: cse321 or equivalent Textbook: The C Programming Language, Kernighan & Ritchie Newsgroup: cse.course.cse45921, the main forum of class communication Office hour stop-by or appointments

Syllabus: Lectures: Ten lectures covering Ch. 1-8, Ch. 2-3, read on your own Occasional pop quizzes Labs: Four labs, 20% each Electronic submission run on stdlinux.cse.ohio-state.edu lab quality, correctness Additional emphasis on Coding style and Makefile Exams: None, but all others count

A little history: 1970’s Unix C, from BCPL (Thompson and Ritchie) C programming Language Widely used like the others: Fortran, Pascal Main form of language for system programming Available on any machine with C compiler and library

Some Characteristics: Scope : Intended: HPC, OS, general programming Typically, long developing cycle very platform dependent Not intended: web, scripting, data processing Features: Close interaction with system Standard library (user-level only), no other fancy stuff: networking, memory, graphics Extensive use of pointers Procedure programming, strictly pass by value

Sample 1: /* Hello World! */ #include int main() { printf(“Hello World!\n”); return 0; }

Walk through: C program: hello.c emacs, vi, vim, pico, joe … But text editors only. No word processor Preprocessing: hello.s, assembly code cc -S hello.c Compilation: hello.o, a binary file cc -c hello.s Linking: a.out or hello, an executable file cc hello.o cc -o hello hello.o Loading (dynamical linking) and execution:./hello./a.out./hello

Programming (Editing) C program: hello.c emacs, vi, vim, pico, joe … But text editors only. No word processor

Compile: Preprocessing: hello.s, assembly code cc -S hello.c Can you take a look at hello.s and compare to hello.c? Compilation: hello.o, a binary file cc -c hello.s Do you know how to take a look at hello.o? Linking: a.out or hello, an executable file cc hello.o cc -o hello hello.o Want to look at the executable, hello?

Run: Loading (dynamical linking) and execute:./hello./a.out./hello What you do with java programs? What computer does to run your program?

Sample 1 Dissection: What it has? A function definition: main A line of comment A line of preprocessor directive An output statement A return clause What it does? Ask the computer to say hello to the world. What it does not do? It seems not computing!! No real work not taking input does not change any value

Sample 2: #include #define MAGIC 10 int main(void) { int i, fact, quotient; while (i++ < 3) { printf(”Guess a factor of MAGIC larger than 1: "); scanf("%d”, &fact); quotient = MAGIC % fact; if (0 == quotient) printf(”You got it!\n”); else printf(”Sorry, You missed it!\n”); } return 0; }

Sample 2 Dissection: What more it has? Macro definition Variable declaration Operations represented by operators Conditional computation Input Processing Loops: three chances

Syntax Dissection: What is syntax? m-w.com: the way in which linguistic elements (as words) are put together to form constituents (as phrases or clauses) How to put your C elements together into a program? Variable declaration, Identifier: case, keywords, style datatype specification char, short, int, long, float, double Operators: +, -, *, /, %, ++, --; >, <, ==, ; &, |, … Priority and Precedence Associativity

More Syntax Dissection: Preprocessor directive macro header file inclusion Loop constructs for, while, do-while, break, continue, label--go; Conditional statements If, else, else if, switch, break Function definition return type, parameter definition, parameter passing Standard library and function calls Take home practice: Walk through the following steps with sample 2 preprocessing, compilation, linking, loading/execute Modify and repeat once more if you can