CISC105 - PowerPoint PPT Presentation

About This Presentation
Title:

CISC105

Description:

CISC105 General Computer Science. Class 7 06/26/2006 ... Order of Operation. Parenthesis, Function Calls, (! - &) Unary Operators, ... – PowerPoint PPT presentation

Number of Views:14
Avg rating:3.0/5.0
Slides: 12
Provided by: michaelh66
Category:

less

Transcript and Presenter's Notes

Title: CISC105


1
CISC105 General Computer Science
  • Class 7 06/26/2006

2
What we should know about writing Programs in C
  • Structure of a Program
  • Preprocessor Directives (include, define)
  • Variable Types
  • int, double, char
  • Input/Output Functions
  • scanf, printf (formatting Output)
  • Variable Manipulation
  • Order of Operation
  • Parenthesis, Function Calls, (! - ) Unary
    Operators, / , - ,lt lt gt gt, !, , ,

3
What we should know about writing Programs in C
  • Functions
  • Declaration, Definition, Use
  • Selection Structures
  • if, ifelse, Nested if
  • Repetition Structures
  • while, dowhile, for, Nested Loops

4
How memory works in programs
  • Memory
  • Address Location in memory
  • Content what is in the location
  • Amount Used depends on the type of Variable
  • Program
  • Main Function
  • Variables
  • Arguments, Formal Parameters and Functions

5
Functions and Memory
  • We have learned that arguments provide a link
    between functions
  • Functions run in separate memory with separate
    values
  • The operator returns the memory address of a
    variable
  • Example pointer.1.c and pointer.1.1.c

6
Pointers
  • We can declare a variable that contains the
    memory address of another variable.
  • To declare a pointer we declare using an
  • int y - declare a variable y that contains the
    address of an integer
  • y can only be set to the address of an integery
    x
  • To access the value at memory location pointed to
    by y you need to use an printf(Value of
    contents at location pointed to by y is d, y)
  • See example pointer.2.c

7
Function Call by Value
  • We have learned that when we call a function and
    pass and argument the argument value is not
    changed in the main function.
  • See Example pointer.3.c

8
Function Call by Reference
  • By using pointers and passing memory address as
    arguments we can change the values in the calling
    function.
  • See example pointer.4.c

9
Three Uses of Operator
  • Multiplication Operator (a b c )
  • Pointer Declaration (int y )
  • Follow the pointer ( y 200 )
  • See example pointer.5.c

10
Passing Input/Output in a single Function
  • You can pass arguments by reference that act as
    input output (Example pointer.6.c)
  • You can call functions multiple time by passing
    different variables by reference as input
    output (Example pointer.7.c)

11
Scope of Variables
  • Scope of a name is the region in a program where
    a particular meaning of a name is valid
  • Global available to every function in the
    program
  • Local available only within the function where
    it is declared
  • Overridden a global variable name can be
    inaccessible to a function if a variable of the
    same name is declared locally
Write a Comment
User Comments (0)
About PowerShow.com