Lecture01 - 0306-381 Applied Programming Lecture One:...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 0306-381 Applied Programming Lecture One: Introduction • Course • C Language Course Information Resources • Syllabus • Schedule • myCourses 2 Prerequisite Math Topics Mathematical concepts • Function properties Domain, range, continuity, limits, approximation, convergence, derivative, and integral • Infinite series and Taylor series expansion • Differential equations • Linear independence • Matrices 3 Prerequisite CS Topics Programming Techniques • Pointers • Data Structures (e.g., lists, queues, and trees) • Searching • Functional Decomposition • Principles of file I/O • Recursion 4 Computing Platform • CE cluster – Head node cluster.ce.rit.edu • Initial ssh login • turnin submission program – Compute nodes (numbered 0-14) node-nn where nn Î [01,14] • ssh to run executable • qlogin for automatic load balance • Only ssh logins accepted – Putty – WinSCP 5 Programming Homework Submission Cluster’s turnin program • Syntax turnin grader381 [hwn [file]] • Without either argument, gives all due dates • Without file, gives submission status for hwn • With all arguments, accepts file (Overwrites any previous submission) • Only works on head node of cluster 6 Motivation I “Every simplification of the procedures of numerical calculation is an advance of quite general usefulness, by relieving researchers of the boredom and fatigue which accompany calculation, by avoiding the loss of time which it entails, and finally by reducing the chances of error which it involves.” M. d’Ocagne, Simplified Calculation, 1986, from The Universal History of Computing by Georges Ifrah, 2001. 7 Motivation II “If you cannot calculate, you cannot speculate on future pleasure, and your life will not be that of a human, but of an oyster or a jellyfish.” Plato (428-347 BC), On Pleasure, 1986, from The Universal History of Computing by Georges Ifrah, 2001. 8 Getting the correct answer is not the most important part of the solution. “I think you should be more explicit here in step two.” Copyright 1999 by Sidney Harris 9 Why C? You already know C++; why not program in it? • Performance – Speed requirements dictate minimal overhead. – C++ has significant overhead compared to C. – Assembly language may be required if speed is critical. • Availability – Many applications use minimal processing elements. – There is not a C++ compiler for every microprocessor or microcontroller, which is often used in embedded applications – There is almost always a C compiler. 10 What is there to learn about C? C++: a superset of C • In theory—nothing to learn Just know which parts of C++ can not be used • In practice—not all of C++ has been learned In particular, the parts of C++ that can be used (i.e., plain C parts) 11 Conceptual C differences from C++? • Not object-oriented “Top-down” design—functional decomposition • No classes Data and functions organized in modules • No objects—no constructors/destructors Variables—initialization Þ writing C code Functions • No methods • No dynamic scope for variables Static scope throughout containing function/program 12 Functional C differences from C++? • No I/O streams scanf() and printf() functions • No new and delete memory allocation malloc() and free() functions • No // comment delimiters /* begins comment; */ ends comment Although gcc accepts C++ // comments, many C compilers will not, so do not use //. • Type casting (DesiredType) ItemToCast • No assignment operator for composite types = only between intrinsic types Allowed by gcc but not all C compilers—avoid 13 Similarities between C and C++ • Same language constructs if(), while(), for(), switch(), etc. • Same intrinsic data types and modifiers char, int, float, double, etc. • Mostly same modifiers short/long, signed/unsigned, and volatile/static Not const—# define • Same pointer usage – &Variable: address (“andress”) of Variable – *Pointer: Memory[Pointer] 14 Typemarks in C: typedef • Sizes of intrinsic types vary by machine. • Many applications require a specific data size, (e.g., 8-bit integer, 64-bit floating point, etc.). • Typemarks clarify intended data size —even for intrinsic types – typedef char Int8; – typedef short int Int16; • typedef allocates no storage 15 Composite types • Array: type Variable[NumberElements] – int Table[100]; ® An array of 100 ints indexed from 0 to 99 – Table[0]; ® First element of Table – Table is equivalent to &(Table[0]) ® Pointer (int *) to first element of Table • Record: struct { components } Use of typemark avoids anonymous type typedef struct { float X, Y } Point2D; 16 Functions • All C code is organized in functions • Any needed parameters should be passed explicitly to a function Do not use global variables—never in this course— (i.e., variables defined outside of any function). • All functions belong to the same name space. Þ All functions must have unique names. 17 Modules • A module is a pair of files. – Code file: program code – Header file: typemarks and function prototypes for program code • Modules can be compiled separately – Compiles to object file. – Not restricted to related functions/declarations. 18 C Program Structure 1. 2. 3. 4. 5. Descriptive comment header block Include file specifications Constant definitions via #defines Typemarks Functions a. b. c. d. Return type, name, and parameters Descriptive comment header block Function variable declarations Function code F Descriptive comments are expected throughout. There is a significant grading penalty for poorly commented programs. 19 ...
View Full Document

This note was uploaded on 04/27/2010 for the course EECC 0306-381 taught by Professor Roymelton during the Spring '10 term at RIT.

Ask a homework question - tutors are online