CSE 459'21: Programming in C - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

CSE 459'21: Programming in C

Description:

Office Hour: Tuesday 1:00--2:00PM. Course Information: Course Page: ... The C Programming Language, Kernighan & Ritchie. Syllabus: Lectures: ... m-w.com: ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 13
Provided by: weiku
Category:
Tags: cse | com | mw | programming

less

Transcript and Presenter's Notes

Title: CSE 459'21: Programming in C


1
CSE 459.21 Programming in C
  • Instructor Na Li
  • Email lina_at_cse.ohio-state.edu
  • Phone 614-292-0056
  • Office DL 274 (Dreese Laboratories)
  • Office Hour Tuesday 100--200PM

2
Course Information
  • Course Page
  • http//www.cse.ohio-state.edu/lina/teaching/cse45
    9-21/
  • Prerequisite
  • cse321 or equivalent
  • Textbook
  • The C Programming Language, Kernighan Ritchie

3
Syllabus
  • Lectures
  • Chapter 1-8 will be covered.
  • Labs
  • Four labs
  • Electronic submission
  • run on stdsun.cse.ohio-state.edu
  • lab quality, correctness
  • Try to develop good coding style
  • Exams
  • No exams

4
A little history
  • 1970s
  • Unix
  • C, from B, 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

5
Sample 1
  • / Hello World! /
  • include ltstdio.hgt
  • int main()
  • printf(Hello World!\n)
  • return 0

6
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

7
Sample 2
  • include ltstdio.hgt
  • define MAGIC 10
  • int main(void)
  • int i0
  • int factor, remainder
  • while (i lt 3)
  • printf(Guess a factor of MAGIC larger
    than 1 ")
  • scanf("d, factor)
  • remainder MAGIC factor
  • if (remainder 0)
  • printf(You got it!\n)
  • else
  • printf(Sorry, You missed it!\n)
  • return 0

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

9
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
  • , -, , /, , , --, gt, lt, , , ,
  • Priority and Precedence
  • Associativity

10
More
  • Preprocessor directive
  • macro
  • header file inclusion
  • Loop constructs
  • for, while, do-while, break, continue, label--go
  • Conditional statements
  • If else, ifelse if, switch, break
  • Function definition
  • return type, parameter definition, parameter
    passing
  • Standard library and function calls

11
Walk through
  • C program hello.c
  • emacs, vi, vim, pico, joe
  • Compilation hello.o, a binary file
  • gcc -c hello.c
  • Linking a.out or hello, an executable file
  • gcc hello.o
  • gcc -o hello hello.o
  • Loading (dynamical linking) and execution
    ./hello
  • ./a.out
  • ./hello

12
Take home practice
  • Walk through sampe1 and sample2
  • preprocessing, compilation, linking,
    loading/execute
  • Modify and repeat once more if you can
  • I will put the instructions on course webpage
    today.
Write a Comment
User Comments (0)
About PowerShow.com