CNG 140 C Programming 2012-2013 Fall Semester Syllabus Course Info Catalog Description Advanced programming with C: Storage and control structures, recursion and programming with dynamic data structures. Homeworks are required to run on UNIX environment. Credits 3+2 Category Content Departmental Prerequisites None Lecture Time and Place Thursday 13:40, 14:40, 15:40 [I-103] Tolga Can Lab Time and Place Tuesday 13:40, 14:40 [I-103] Uğur Dönmez Text Book A First Book of ANSI C, G.J. Bronson, 4 th Edition, Thomson Learning, 2007. ISBN: 1418835560 Reference Books Programming in ANSI C, Kumar & Agrawal, WEST Publishing Co., 1992. ISBN: 0-314-89563-9 The C Programming Language, Kernighan & Ritchie, 2 nd Edition, Prentice Hall, 1988. ISBN: 0131103628 Instructor Tolga Can, TZ-30, tcan@ceng.metu.edu.tr Teaching Assistant Uğur Dönmez, office and e-mail to be announced
Course Conduct CNG 140 is a non-introductory course for programming in C. So, both material wise and conduct wise it is structured as an advanced course. C is the foundation stone of today's professional programming and there is no indication that this will change in the near future. The purpose of this course is to equip our students with professional level C programming skills. The course is structured on the following materials: 1. Text book 2. Lectures 3. Labs 4. Homeworks The followings are to be mentioned: In a classical course the lectures and the text book are functionally equivalent. So, lectures are confined to cover the text book material in a verbal manner. This is not so for CNG 140. Though the intersection of the Text book and Lecture content is non empty, it is also not equal to the union of them. There is a good deal of content which is not covered in the lecture but is expected to be acquired through reading of the book. Also there is a good deal of content which is not stated in the book but introduced in the lecture. When attending lectures, it is expected that the student has read the part of the text book which will be announced weekly. Without having done this reading, it is not possible to follow the lectures and have an understanding of what is going on. Labs: Every week for two hours you will practice that week s subject in the lab under the guidance of the teaching assistant. There will be practice problems which you will solve in the lab. You will not be graded from your lab performance; however, attendance to the lab hours is mandatory. You need to attend 80% of the lab hours to be eligible to take the final exam. Otherwise, you will not be allowed to take the final exam and get a grade of NA from the course, which will also prevent you to take the re-sit exam. Homeworks: There will be 4 Homeworks throughout the semester. All of the homeworks will be C programming tasks and will be graded automatically (by means of a grader program). So, you need to strictly adhere to the input/output specifications given in the homework description. Though the input/output testing of an Homework will be a blackbox test, your source code will be investigated for neatness and cheating. All the homeworks will required to be implemented
individually and any code sharing will be considered as cheating and you will get a 0 (zero) grade for that homework automatically. Usually you will have 2 weeks of time to turn your homeworks in. This time shall be used properly. The level of the homeworks are so that a hard work on the last 2-3 days will not suffice. You are strongly advised to start concentrating on the homework right after you received it. Lectures: Attendance to lectures is mandatory. Attendance will be taken at the beginning of each hour. In order to be eligible to take the final exam, you need to attend 70% of the lecture hours. Otherwise, you will get a grade of NA automatically which will not allow you to take neither the final exam nor the resit exam. Course Outline 1. General Overview of Programming 2. Sequential Structure o Data Types and Classes of Data o Arithmetic and Logical Operators and Expressions o Assignment (concept of l-value, r-value) o Statements o Grouping of expressions and statements o Basic I/O o Type Conversion (Dynamic, Explicit) 3. Selective Structure o Conditional Expression and Statements o Nested Conditionals o Multiway Conditional 4. Repetitive Structure o while loop o do while loop o for loop o Nested Loops o Loop Interruption break, continue statements 5. Functions o Function Definition o Function Call o Function Prototypes (header files) o Storage Classes (auto, static variables) o Separate Compilation and Data Abstraction o Recursion 6. Arrays and Pointers o Basics of Pointers o Array Pointer Referencing Duality o Strings o Dynamic Memory Management o Function and Pointers (call-by-reference)
o Multidimensional Arrays and Pointers o Pointers to Pointers 7. Structures and Unions o Basics of Structures o Structures and Functions o Structures and Arrays o Structures Containing Pointers (self-referential structures) o Unions 8. Advanced Use of the Preprocessor o This will be introduced in parallel to the topic of 'Structures'. 9. Operations on Bits o Bitwise Logical Operators o Bitwise Shift Operators o Bit-fields 10. File Processing o File Access (sequential) o Formatted I/O o Characterwise and Bytewise I/O o Random File Access Weekly Coverage Week-1 o Info on course conduct o Where is C in the space of programming paradigms o BNF notation o Basic layout of a C program o Basic types, Identifiers, Variables, 1-Dim arrays, Constants, sizeof() o Simple use of #define macro o Naming conventions o Assignment operator Week-2 (Week-1 continued) o Info on course conduct o Where is C in the space of programming paradigms o BNF notation o Basic layout of a C program o Basic types, Identifiers, Variables, 1-Dim arrays, Constants, sizeof() o Simple use of #define macro o Naming conventions o Assignment operator Week-3 o Operators, Boolean operators o Concept of 'side effect', Church-Rosser property, overflow o Precedence, associativity o l-value, r-value, ++ o Casting (auto, user demanded)
Week-4 o Conditional expression o Statements in C o if statement o Repetitive statements: while, do-while, for o switch statement o Unconditional branching, goto Distribution of Homework #1 Week-5 o Functions o Recursion o Dynamic vs Static binding, auto/static variable o Internals of a function call: Activation record o Modular programming (Header file, external variable and functions) o Separate Compilation and Data Abstraction o 2-Dim arrays Week-6 (Week-5 continued) o Functions o Recursion o Dynamic vs Static binding, auto/static variable o Internals of a function call: Activation record o Modular programming (Header file, external variable and functions) o Separate Compilation and Data Abstraction o 2-Dim arrays Distribution of Homework #2 Week-7 o Arrays, multidimensional arrays o Pointers o Pointer arithmetic o Pointer - Array relation Week-8 o Dynamic Memory Management (malloc, realloc,free) o Function and Pointers (call-by-reference) o Multidimensional Arrays and Pointers Midterm Examination (November 22) (Week 9) Week-10 o Strings o Examples on pointers and strings
Distribution of Homework #3 Week-11 o Structures o Preprocessor, define macro o typedef o [Example: linked lists] Week-12 o More on structures, variable length structures o Union o Bitwise operations Distribution of Homework #4 Week-13 Week-14 o Streams, Files o Sequential, Random access o Raw (binary) mode o Data portability, Persistence o Semester overview o More examples on pointers, strings, functions Grading Policy Homeworks 40% Midterm Exam 30% Final Exam 30% If you are caught cheating in an exam, you will get a grade of 0 (zero) for that exam. You must attend 80% of the labs and 70% of the lectures in order to be eligible to take the final exam. Otherwise, you will get a grade of NA from the course.