CGS3460 Summer 2011 Programming Using C Andrei Todor
Syllabus Class Study Program Homework (25%) Quiz (25%) Midterm(25%) Final(25%)
Computer Programming Program Computer program Problem – General - e.g.: find minimum of a list of numbers – Instance - e.g.: find minimum of 3,4,-1 Solution – General: e.g.: look at each number – Instance: -1
Computer Programming Algorithm – Solution to a general problem – Input: instance of the problem – Output: solution for the instance of general problem Pseudocode – Formal description of steps – E.g. Store the value of the first number Look at each number and if it is smaller than the stored value, replace it Output the stored value
Computer Programming Machine Language – E.g.: Programming language – Between pseudocode and machine language – E.g.: C – Syntax (grammar) Compiler – e. g. gcc Execution
Computer Programming Errors – Syntax – compile time – Logical (bug) – run time Debugger
Overview Solution/AlgorithmProblem Pseudocode Program/Source Code Programming Language (C) Executable Program Machine Language PaperText file Binary file Paper solve English code implement compile Output (Solution to problem instance) execute Input Data (Problem instance)
Programming Environment Get class account – – UNIX servers thunder.cise.ufl.edu storm.cise.ufl.edu
Programming environment Remote terminal access Remote file transfer EditorCompilerIDE UNIX – local (CISE labs) NA emacs gedit gccKDevelop UNIX – remote (other Unix computers) local, ssh,sftpemacsgccNA Windows&UNIXPuttyWinSCPemacsgccNA WindowsNA VimMinGWDev-C++ Visual Studio
Basic UNIX Use Putty to connect to thunder Working directory: pwd, cd,. Up directory:.. Home directory: ~
First C program emacs hello.c CTRL+X CTRL+C to save gcc hello.c Execute gcc argument –o Details of gcc – Preprocessing – Compilation – Link-editing
C syntax BNF ::= ::= [ ] ::= |… ::= #include >
C syntax ::= [ ] ::= ::= ::= { [declarations][ ] }
C syntax ::= [ ] ::= ; | |… ::= | |…
C syntax ::= |… ::= ::= ([,…]) ::=return
C Syntax ::= | ::=[-]digits[.][digits] ::= [ ] ::=0|1|…|9 ::=“ ” ::= ::=A|B|…|z|0|…|9|(|)|!| |.|*|…