Symbolic Constants in CCS-2303, C-Term 20101 Digression – Symbolic Constants in C CS-2303, System Programming Concepts (Slides include materials from The.

Slides:



Advertisements
Similar presentations
Binary TreesCS-2303, C-Term Binary Trees (and Big “O” notation) CS-2303 System Programming Concepts (Slides include materials from The C Programming.
Advertisements

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.
Derived Classes in C++CS-2303, C-Term Derived Classes in C++ CS-2303 System Programming Concepts (Slides include materials from The C Programming.
Event-drive SimulationCS-2303, C-Term Project #3 – Event-driven Simulation CS-2303 System Programming Concepts (Slides include materials from The.
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.
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.
Arrays in C & C++CS-2303, C-Term Arrays in C & C++ (including a brief introduction to pointers) CS-2303 System Programming Concepts (Slides include.
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.
Display a 12-Month Calendar CS-2301 D-term Programming Assignment #2 12-Month Calendar CS-2301 System Programming C-term 2009 (Slides include materials.
Discussion of Assignment #2 CS-2301, B-Term Discussion of Assignment #2 CS-2301, System Programming for Non-Majors (Slides include materials from.
Loose endsCS-2301, B-Term “Loose Ends” CS-2301, System Programming for Non-Majors (Slides include materials from The C Programming Language, 2 nd.
More Miscellaneous Topics CS-2301 B-term More Miscellaneous Topics CS-2301, System Programming for Non-majors (Slides include materials from The.
Programming Assignment #4 Binary Trees
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 Operator Overloading CS-2303, C-Term More on Operator Overloading CS-2303 System Programming Concepts (Slides include materials from The.
Numerical Computation in C CS-2301 D-term Numerical Computation in C CS-2301 System Programming for Non-majors, C-term 2009 (Slides include materials.
Digression on Loop Invariants CS-2303, C-Term Digression on Loop Invariants CS-2303, System Programming Concepts (Slides include materials from The.
Scope Rules and Storage Types CS-2303, C-Term Scope Rules and Storage Types CS-2303, System Programming Concepts (Slides include materials from The.
A Deeper Look at Classes CS-2303, C-Term A Deeper Look at Classes CS-2303 System Programming Concepts (Slides include materials from The C Programming.
Conditionals, Loops, and Other Statements CS-2301 D-term Conditionals, Loops, and Other Kinds of Statements CS-2301 System Programming C-term 2009.
Miscellaneous topicsCS-2301 B-term Miscellaneous Topics CS-2301, System Programming for Non-majors (Slides include materials from The C Programming.
Accessing Files in CCS-2303, C-Term Accessing Files in C CS-2303 System Programming Concepts (Slides include materials from The C Programming Language,
More about the C Preprocessor CS-2303, C-Term More about the C Preprocessor CS-2303 System Programming Concepts (Slides include materials from The.
Introduction to C++CS-2303, C-Term Introduction to C++ CS-2303 System Programming Concepts (Slides include materials from The C Programming Language,
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.
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.
Assignment #2, 12- month Calendar CS-2301, B-Term Programming Assignment #2 12-Month Calendar CS-2301, System Programming for Non-Majors (Slides.
CS-2303 System Programming Concepts
PolymorphismCS-2303, C-Term Polymorphism Hugh C. Lauer Adjunct Professor (Slides include materials from The C Programming Language, 2 nd edition,
Conditionals, Loops, and Other Statements CS-2301, B-Term Conditionals, Loops, and Other Kinds of Statements CS-2301, System Programming for Non-Majors.
Operator OverloadingCS-2303, C-Term Operator Overloading CS-2303 System Programming Concepts (Slides include materials from The C Programming Language,
CS 11 C track: lecture 1 Preliminaries Need a CS cluster account cgi-bin/sysadmin/account_request.cgi Need to know UNIX ITS.
Microsoft PowerPoint How to make a PowerPoint. Getting Started  Click on to open PowerPoint  Click on Format > Slide Design  Slide designs will show.
Numerical Computation in C C Programming by Ali iskurt 1 Numerical Computation in C Computer Programmin in C Fall Semester (Slides include materials.
CHAPTER # 2 Part 2 PROGRAMS AND DATA 1 st semster King Saud University College of Applied studies and Community Service CSC1101 By: Asma Alosaimi.
Bit Fields & Bitwise Operations CS-2303, C-Term Bit Fields & Bitwise Operations CS-2303 System Programming Concepts (Slides include materials from.
CS 261 – Data Structures Introduction to C Programming.
Programming Fundamentals. Summary of previous lectures Programming Language Phases of C++ Environment Variables and Data Types.
Chapter # 2 Part 2 Programs And data
C Programming Hardik H. Maheta.
History of ‘C’ Root of the morden language is ALGOL It’s first
Welcome In The World Of ‘C’.  TEXT BOOK: Programming in ANSI ‘C By: E Balagurusamy. TMH  Reference Books: 1) The ‘C Programming Language By: Kernighan.
Programming Assignment #4 Binary Trees in C++
More about Numerical Computation
Makefiles and Notes on Programming Assignment PA2
Classes, Constructors, etc., in C++
Miscellaneous C++ Topics
Structures, Unions, and Typedefs
Binary Trees (and Big “O” notation)
Polymorphism Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition, by Kernighan.
Programming Assignment #1 12-Month Calendar—
Templates (again) Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition,
Symbolic Constants in C
Programming Assignment #6
Scope Rules and Storage Types
How to Change the Images
Programming Assignment #5
Differences between Java and C
Your first C and C++ programs
Chapter # 2 Part 2 Programs And data
Operator Overloading Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition,
Digression on Loop Invariants
A Deeper Look at Classes
Introduction to Classes and Objects
Presentation transcript:

Symbolic Constants in CCS-2303, C-Term Digression – Symbolic Constants in C CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie and from C: How to Program, 5 th and 6 th editions, by Deitel and Deitel)

Symbolic Constants in CCS-2303, C-Term Specifying Symbolic Constants in C Two ways –Textual substitution –Declaration of const data object

Symbolic Constants in CCS-2303, C-Term Constant – Textual Substitution See page 14 & 89 in K&R 215 in D&D #define NAME replacement-text E.g., #define PI #define LOWER 0 #define UPPER 300 #define STEP 20 It is traditional in C for textual substitution names to be all UPPER CASE A preprocessor directive!

Symbolic Constants in CCS-2303, C-Term Constant – Textual Substitution See page 14 & 89 in K&R #define NAME replacement-text E.g., #define PI #define LOWER 0 #define UPPER 300 #define STEP 20 When a textual substitution constant is used in a program, the compiler simply substitutes the replacement text on the fly

Symbolic Constants in CCS-2303, C-Term Constant Declaration const double pi = ; const double c = e+8; /* speed of light in meters/sec */ Defines a value of the declared type with the declared name I.e., creates storage to hold this value Must be initialized May never be left side of an assignment

Symbolic Constants in CCS-2303, C-Term Questions? Next Topic