More Miscellaneous Topics CS-2301 B-term 20081 More Miscellaneous Topics CS-2301, System Programming for Non-majors (Slides include materials from The.

Slides:



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

void count_down (int count) { for(i=count; i>1; i--) printf(" %d\t", count); } printf("A%d\n", count); if(count>1) count_down(count-1); printf("B%d\n",
Homework #4CS-2301 B-term Homework #4 Strings, Arrays, and malloc() CS-2301, System Programming for Non-majors (Slides include materials from The.
Linked Lists in C and C++ CS-2303, C-Term Linked Lists in C and C++ CS-2303 System Programming Concepts (Slides include materials from The C Programming.
Introduction to Operating Systems CS-2301 B-term Introduction to Operating Systems CS-2301, System Programming for Non-majors (Slides include materials.
File AccessCS-2301, B-Term File Access CS-2301, System Programming for Non-Majors (Slides include materials from The C Programming Language, 2 nd.
Arrays in CCS-2301, B-Term Arrays in C (including a brief introduction to pointers) CS-2301, System Programming for Non-Majors (Slides include materials.
Strings and Dynamic Memory Allocation CS-2301, B-Term Programming Assignment #6 Strings and Dynamic Memory Allocation CS-2301, System Programming.
Numerical Computation Review and Continuation CS-2301, B-Term Numerical Computation in C Review and Continuation CS-2301, System Programming for.
Lists and Trees (continued) CS-2301, B-Term Lists and Trees (continued) CS-2301, System Programming for Non-Majors (Slides include materials from.
More on Data Structures in C CS-2301 B-term More on Lists and Trees Introduction to Hash Tables CS-2301, System Programming for Non-majors (Slides.
Structures, Unions, and Typedefs CS-2301 D-term Structures, Unions, and Typedefs CS-2301 System Programming D-term 2009 (Slides include materials.
Differences between Java and C CS-2303, C-Term Differences between Java and C CS-2303, System Programming Concepts (Slides include materials from.
Discussion of Assignment #2 CS-2301, B-Term Discussion of Assignment #2 CS-2301, System Programming for Non-Majors (Slides include materials from.
Review of Exam #2CS-2301, B-Term Review of Exam #2 CS-2301, System Programming for Non-Majors (Slides include materials from The C Programming Language,
Loose endsCS-2301, B-Term “Loose Ends” CS-2301, System Programming for Non-Majors (Slides include materials from The C Programming Language, 2 nd.
Hash TablesCS-2301, B-Term Hash Tables and Constant Access Time CS-2301, System Programming for Non-Majors (Slides include materials from The C Programming.
Arrays in CCS-2301 B-term Arrays in C (with a brief Introduction to Pointers) CS-2301, System Programming for Non-majors (Slides include materials.
"Loose ends"CS-2301 D-term “Loose Ends” CS-2301 System Programming C-term 2009 (Slides include materials from The C Programming Language, 2 nd edition,
More on Numerical Computation CS-2301 B-term More on Numerical Computation CS-2301, System Programming for Non-majors (Slides include materials from.
More on FunctionsCS-2301 B-term More on Functions CS-2301, System Programming for Non-majors (Slides include materials from The C Programming Language,
More on Operator Overloading CS-2303, C-Term More on Operator Overloading CS-2303 System Programming Concepts (Slides include materials from The.
Introduction to FunctionsCS-2301 B-term Introduction to Functions CS-2301, System Programming for Non-majors (Slides include materials from The.
C and Data Structures Baojian Hua
Scope Rules and Storage Types CS-2303, C-Term Scope Rules and Storage Types CS-2303, System Programming Concepts (Slides include materials from The.
Structures and UnionsCS-2301 B-term Structures and Unions CS-2301, System Programming for Non-majors (Slides include materials from The C Programming.
Miscellaneous topicsCS-2301 B-term Miscellaneous Topics CS-2301, System Programming for Non-majors (Slides include materials from The C Programming.
More about Numerical Computation CS-2301, B-Term More about Numerical Computation CS-2301, System Programming for Non-Majors (Slides include materials.
 2006 Pearson Education, Inc. All rights reserved. Templates (again)CS-2303, C-Term Templates (again) CS-2303 System Programming Concepts (Slides.
Recursion and Function Implementation CS-2301 D-term Recursion and Implementation of Functions CS-2301 System Programming C-term 2009 (Slides include.
Introduction to Classes and Objects CS-2303, C-Term Introduction to Classes and Objects CS-2303 System Programming Concepts (Slides include materials.
Structures, Unions, and Typedefs CS-2303, C-Term Structures, Unions, and Typedefs CS-2303 System Programming Concepts (Slides include materials from.
Pointers Example Use int main() { int *x; int y; int z; y = 10; x = &y; y = 11; *x = 12; z = 15; x = &z; *x = 5; z = 8; printf(“%d %d %d\n”, *x, y, z);
Data Structures, Lists, and Trees CS-2301 B-term Data Structures — Lists and Trees CS-2301, System Programming for Non-majors (Slides include materials.
CS2422 Assembly Language & System Programming November 7, 2006.
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
Recursion and Implementation of Functions
Data Structures — Lists and Trees CS-2301, B-Term Data Structures — Lists and Trees CS-2301, System Programming for Non-Majors (Slides include materials.
CS 11 C track: lecture 1 Preliminaries Need a CS cluster account cgi-bin/sysadmin/account_request.cgi Need to know UNIX ITS.
Recursion Examples Fundamentals of CS Case 1: Code /* Recursion: Case 1 */ #include void count (int index); main () { count (0); getchar(); } void count.
Stacks & Recursion. Stack pushpop LIFO list - only top element is visible top.
History of C 1950 – FORTRAN (Formula Translator) 1959 – COBOL (Common Business Oriented Language) 1971 – Pascal Between Ada.
Arrays in C.
Introduction to Operating Systems CS-2301 B-term Introduction to Operating Systems (continued) CS-2301, System Programming for Non-majors (Slides.
DOCUMENTATION SECTION GLOBAL DECLARATION SECTION
Slide Advanced Programming 2004, based on LY Stefanus's slides Native Methods.
C Programming Chapters 11, . . .
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
Free Ebooks Download Mba Ebooks By Edhole Mba ebooks Free ebooks download
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.
RecursionCIS 1057 Fall Recursion CIS 1057 Computer Programming in C Fall 2013 (Many slides based on/borrowed from Professor Hugh C. Lauer. Slides.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
C Interview Questions Prepared By:.
C Language By Sra Sontisirikit
Introduction to C Topics Compilation Using the gcc Compiler
Introduction to C Topics Compilation Using the gcc Compiler
Pointers.
Makefiles and Notes on Programming Assignment PA2
Miscellaneous C++ Topics
Binary Trees (and Big “O” notation)
Templates (again) Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition,
Recursion and Implementation of Functions
Scope Rules and Storage Types
Programming Fundamentals Lecture #3 Overview of Computer Programming
Differences between Java and C
Your first C and C++ programs
Introduction to C Topics Compilation Using the gcc Compiler
Introduction to C CS 3410.
Introduction to Classes and Objects
Presentation transcript:

More Miscellaneous Topics CS-2301 B-term More Miscellaneous Topics CS-2301, System Programming for Non-majors (Slides include materials from The C Programming Language, 2 nd ed., by Kernighan and Ritchie and from C: How to Program, 5 th ed., by Deitel and Deitel)

More Miscellaneous Topics CS-2301 B-term Recursive Functions – Exam Question 9 void move (int disks, int a, int c, int b){ if (disks > 0){ move (disks-1, a, b, c); printf ("Move one disk from %d to %d\n", a, c); move (disks-1, b, c, a); } return; } How many calls to move for disks = 0 ? How many disks are moved for disks = 0 ?

More Miscellaneous Topics CS-2301 B-term Recursive Functions – Exam Question 9 void move (int disks, int a, int c, int b){ if (disks > 0){ move (disks-1, a, b, c); printf ("Move one disk from %d to %d\n", a, c); move (disks-1, b, c, a); } return; } How many calls to move for disks = 0 ?1 How many disks are moved for disks = 0 ?0

More Miscellaneous Topics CS-2301 B-term Recursive Functions – Exam Question 9 void move (int disks, int a, int c, int b){ if (disks > 0){ move (disks-1, a, b, c); printf ("Move one disk from %d to %d\n", a, c); move (disks-1, b, c, a); } return; } How many calls to move for disks = 0 ?1 How many disks are moved for disks = 0 ?0 How many calls to move for disks = 1 ? How many disks are moved for disks = 1 ?

More Miscellaneous Topics CS-2301 B-term Recursive Functions – Exam Question 9 void move (int disks, int a, int c, int b){ if (disks > 0){ move (disks-1, a, b, c); printf ("Move one disk from %d to %d\n", a, c); move (disks-1, b, c, a); } return; } How many calls to move for disks = 0 ?1 How many disks are moved for disks = 0 ?0 How many calls to move for disks = 1 ?3 One for disks = 1 and 2 times disks = 0 – i.e., 1 + 2*1! How many disks are moved for disks = 1 ? 1 One for disks = 1 and 2 times disks = 0 – i.e., 1 + 2*0!

More Miscellaneous Topics CS-2301 B-term Recursive Functions – Exam Question 9 void move (int disks, int a, int c, int b){ if (disks > 0){ move (disks-1, a, b, c); printf ("Move one disk from %d to %d\n", a, c); move (disks-1, b, c, a); } return; } How many calls to move for disks = 1 ?3 How many disks are moved for disks = 1 ?1 How many calls to move for disks = 2 ?7 One for disks = 2 and 2 times disks = 1 – i.e., 1 + 2*3! How many disks are moved for disks = 2 ? 3 One for disks = 2 and 2 times disks = 1 – i.e., 1 + 2*1!

More Miscellaneous Topics CS-2301 B-term Recursive Functions – Exam Question 9 void move (int disks, int a, int c, int b){ if (disks > 0){ move (disks-1, a, b, c); printf ("Move one disk from %d to %d\n", a, c); move (disks-1, b, c, a); } return; } How many calls to move for disks = 2 ?7 How many disks are moved for disks = 2 ?3 How many calls to move for disks = 3 ?15 One for disks = 3 and 2 times disks = 2 – i.e., 1 + 2*7! How many disks are moved for disks = 3 ? 7 One for disks = 3 and 2 times disks = 2 – i.e., 1 + 2*3!

More Miscellaneous Topics CS-2301 B-term Recursive Functions – Exam Question 9 void move (int disks, int a, int c, int b){ if (disks > 0){ move (disks-1, a, b, c); printf ("Move one disk from %d to %d\n", a, c); move (disks-1, b, c, a); } return; } How many calls to move for disks = 3 ?15 How many disks are moved for disks = 3 ?7 How many calls to move for disks = 4 ?31 One for disks = 4 and 2 times disks = 3 – i.e., 1 + 2*15! How many disks are moved for disks = 4 ? 15 One for disks = 4 and 2 times disks = 3 – i.e., 1 + 2*7!

More Miscellaneous Topics CS-2301 B-term Recursive Functions – Exam Question 9 void move (int disks, int a, int c, int b){ if (disks > 0){ move (disks-1, a, b, c); printf ("Move one disk from %d to %d\n", a, c); move (disks-1, b, c, a); } return; } How many calls to move for disks = 3 ?15 How many disks are moved for disks = 3 ?7 How many calls to move for disks = 4 ?31 One for disks = 4 and 2 times disks = 3 – i.e., 1 + 2*15! How many disks are moved for disks = 4 ? 15 One for disks = 4 and 2 times disks = 3 – i.e., 1 + 2*7! Answer for disks = n is simple from the code and disks = n-1

More Miscellaneous Topics CS-2301 B-term Questions?

More Miscellaneous Topics CS-2301 B-term What does C do for you … … at compile time? … at run time?

More Miscellaneous Topics CS-2301 B-term At Compile Time Managing headers, include files, linking, preparation for debugging, etc. Type checking and conversion between numeric types To avoid silly mistakes Managing The Stack Code optimization! Escapes from type rules For people who know what they are doing

More Miscellaneous Topics CS-2301 B-term At Run Time Very little No array bounds checking No pointer checking No validity checking of any kind No protection against run-time mistakes No …… No …

More Miscellaneous Topics CS-2301 B-term C Provides Enough flexibility to program the innermost details of a operating system, device driver, instrument, embedded system A comprehensive library of supporting functions and Enough rope to hang yourself with!

More Miscellaneous Topics CS-2301 B-term Questions?