CS102 Software Engineering Principles

Size: px
Start display at page:

Download "CS102 Software Engineering Principles"

Transcription

1 CS102 Software Engineering Principles Bill Cheng 1

2 Software Engineering Principles You need to develop a plan before you start writing your code Choose the proper data structures Consider what objects you need & how they interact Consider different approaches & their efficiency At some point your code will be too large to fit in your brain all at once CSCI 102 will intentionally push you past this limit From Lab #2 and HW #1 onward, we will start requiring a small design document Let s talk briefly about some software design methodologies 2

3 Waterfall Development Requirements What should the software do? Design How will you meet the reqs? Implementation Write the code Veritifcation Test the code Maintenance Keep it working 3

4 Iterative Development Don t try to do everything at once...go through each stage as many times as necessary! Requirements Analysis & Design Planning Implementation Initial Planning Deployment Evalutaion Testing 4

5 Extreme/Agile Programming XP Practices Whole Team Customer Tests Collective Ownership Pair Programming Continuous Integration Test-driven Development Simple Design Metaphor Coding Standard Refactoring Sustainable Pace Planning Game Small Releases Program in pairs? Write tests first? Weird 5

6 Design Documents From this point onward... All your homework assignments will require a design document to be submitted with your code Most of your lab assignments will require a design document to be submitted Lab design documents must be submitted BEFORE you turn in your lab There is a design document template available on the course website There are links on the main homework & lab pages 6

7 CS102 Basic C++ Memory Management Bill Cheng 7

8 Von Neumann Architecture I/O Devices CPU Memory Connects to: keyboard mouse harddrive printer etc. The Brain, can do: arithmatics logic etc. Contains: program data Put program and data at the same place! 8

9 Memory When you upgrade your laptop s memory, what do you buy? x GB of memory What is an integer? a floating point number? a character? They are just illusions (created by the programming language you use) Memory is just as a bunch of bytes Data structure is just an illusion Why do we need data structures? To organize data stored in memory Make our code easier to maintain, less bugs, etc. Some algorithms run a lot faster if the right data structures are utilized 9

10 Memory Addresses The location of each variable s value in memory is indexed by an address You can talk about the variable named X, or You can alternately talk about the variable that lives at location 1000 int X=102; /* */ 1000 memory address 0x66 content at a memory address 10

11 Memory Addresses The location of each variable s value in memory is indexed by an address You can talk about the variable named X, or You can alternately talk about the variable that lives at location 1000 int X=102; /* */ 1000 memory address 0x66 content at a memory address For int X=102; the above is the wrong picture Need 4 bytes of memory Actually, two choices 11

12 Memory Addresses The location of each variable s value in memory is indexed by an address You can talk about the variable named X, or You can alternately talk about the variable that lives at location 1000 int X=102; /* */ memory address Little-endian 0x66 content at a memory address Ex: Intel 12

13 Memory Addresses The location of each variable s value in memory is indexed by an address You can talk about the variable named X, or You can alternately talk about the variable that lives at location 1000 int X=102; /* */ memory address Big-endian 0x66 content at a memory address Ex: Solaris, PowerPC 13

14 Memory Organization 32-bit address space: Note: if you have a 64-bit machine, things here will be 8 bytes long instead For the rest of the semester, we will assume a 32-bit machine (such as nunki/aludra) Memory Organization code & global/static variables heap 0xffffffff stack Does not have to be all in one large contiguous block Use segments (code segment, data segment, stack segment) Have you heard of segmentation faults? 14

15 Variables Three types of variables Static variable Ex: static int x = 3; Can be inside a function or outside Stack / automatic variable Ex: void foo(int y) int z = y*y; xffffffff Memory Organization code & global/static variables heap stack All local variables live in the stack Heap variable Ex: int *px = (int*)malloc(sizeof(int)); All dynamically allocated variables live in the heap 15

16 Variables and References (Ch 7) Variables Are copied when they are passed into a function Ex: void foo(int y) int z = y*y;... y int main() int x = 102; foo(x); calls foo() main() z x stack 0x28 0x66 0xa4 0x66 x, y, and z all live in the stack x lives in main() s stack frame y and z lives in foo() s stack frame 16

17 Variables and References (Ch 7) References After a reference is created, it cannot be changed Don t have to dereference a reference Why use? Not that useful just being declared in the body of a function As a function parameter, it allows you to modify the original value that was passed in Can use to return multiple values from a function Eliminate the overhead of copying Ex: void foo(int &y) int main() y += 100; int x = 102; foo(x); 17

18 Pointers (Ch 13) Pointers A pointer of any type is a 32-bit number which should be interpreted as an address Pointer variables store a location of something stored elsewhere Rather than refer to a value directly, we can refer to it via its address Why use? Share access to common data (hold onto one copy, everybody points to it) Flexibility (dynamic data structures) Precisely control allocation/deallocation ourselves 18

19 Pointers (Ch 13) static int x = 0x54321; int main() int *p;... 0x20f84 0x05 0x43 0x21 0xffbff74c???? A pointer of any type is a 32-bit number which should be interpreted as an address A pointer of type (X*) with a value of Y means that starting at address Y, interpret it as if there is an object of type X there p contains an address *p means follow the pointer value 19

20 static int x = 5; int main() int *p; p = &x;... Pointers (Ch 13) 0x20f84 0x05 0x43 0x21 0xffbff74c???? A pointer of any type is a 32-bit number which should be interpreted as an address A pointer of type (X*) with a value of Y means that starting at address Y, interpret it as if there is an object of type X there p now contains the address of x 20

21 static int x = 5; int main() int *p; p = &x;... Pointers (Ch 13) 0x20f84 0x05 0x43 0x21 0xffbff74c 0x02 0x0f 0x84 A pointer of any type is a 32-bit number which should be interpreted as an address A pointer of type (X*) with a value of Y means that starting at address Y, interpret it as if there is an object of type X there p now contains the address of x 21

22 static int x = 5; int main() int *p; p = &x;... Pointers (Ch 13) 0x20f84 0x05 0x43 0x21 0xffbff74c A pointer of any type is a 32-bit number which should be interpreted as an address A pointer of type (X*) with a value of Y means that starting at address Y, interpret it as if there is an object of type X there p now contains the address of x usually drawn like a "pointer" starting in p and point to the start of x 22

23 static int x = 5; int main() int *p; p = &x; int y = *p; Pointers (Ch 13) 0x20f84 0x05 0x43 0x21 0xffbff74c 0xffbff750???? A pointer of any type is a 32-bit number which should be interpreted as an address A pointer of type (X*) with a value of Y means that starting at address Y, interpret it as if there is an object of type X there *p means follow the pointer and fetch the content copy that value to y 23

24 static int x = 5; int main() int *p; p = &x; int y = *p; Pointers (Ch 13) 0x20f84 0x05 0x43 0x21 0xffbff74c 0xffbff750 0x05 0x43 0x21 A pointer of any type is a 32-bit number which should be interpreted as an address A pointer of type (X*) with a value of Y means that starting at address Y, interpret it as if there is an object of type X there *p means follow the pointer value and fetch the content copy that value to y 24

25 Pointers Ex: void foo(int *y) (*y) += 100; int main() int x = 102; foo(&x); Pointers (Ch 13) calls foo() main() stack 0xbfffecd0 y 0xbf 0xff 0xbfffedb4 x 0xed 0xb4 0xca 25

26 Pointers Ex: void foo(int *y) (*y) += 100; Pointers (Ch 13) 0x804b008 0xca heap int main() int *px = (int*) malloc(sizeof(int)); if (px!= (int*)0) *px = 102; foo(px); free(px); calls foo() main() stack 0xbfffecd0 y 0x08 0x04 0xb0 0xbfffedb4 px 0x08 0x04 0xb0 0x08 0x08 26

27 Pointers (Ch 13) Pointers Why worry? Must remember to clean up after yourself Usage can be error prone Mistakes don t always show up right away Mistakes can have weird symptoms Memory bugs are hard to understand & fix (even for professionals) 27

28 struct Point char name; int x; int y; ; static Point pt; int main() pt.name = a ; pt.x = 0x12345; pt.y = 0x98765;... All Pointers Are Compatible! 0x20f84 0x20f8c??? 0x01 0x23 0x45 0x09 0x87 0x65 28

29 All Pointers Are Compatible! struct Point char name; int x; int y; ; static Point pt; int main() pt.name = a ; pt.x = 0x12345; pt.y = 0x98765; int *p=(int*)(&pt); cout << hex << "0x" << *p << endl;... 0x x21070??? 0x01 0x23 0x45 0x09 0x87 0x65 0xffbff7bc output: 0x

30 All Pointers Are Compatible! struct Point char name; int x; int y; ; static Point pt; int main() pt.name = a ; pt.x = 0x12345; pt.y = 0x98765; int *p=(int*)(&pt); cout << hex << "0x" << *p << endl; p++; cout << "0x" << setw(8) << setfill( 0 ) << *p << endl;... 0x x21070??? 0x01 0x23 0x45 0x09 0x87 0x65 0xffbff7bc output: 0x

31 All Pointers Are Compatible! struct Point char name; int x; int y; ; static Point pt; int main()... int *p=(int*)(&pt); cout << hex << "0x" << *p << endl; p++; cout << "0x" << setw(8) << setfill( 0 ) << *p << endl; p++; cout << "0x" << setw(8) << setfill( 0 ) << *p << endl; 0x x21070??? 0x01 0x23 0x45 0x09 0x87 0x65 0xffbff7bc output: 0x

32 struct Point char name; int x; int y; ; All Pointers Are Compatible! static int x=0x ; int main() Point *p=(point*)(&x);... 0x20eec 0x67 0x89 0x12 0x34 0xffbff5fc 32

33 struct Point char name; int x; int y; ; All Pointers Are Compatible! static int x=0x ; int main() Point *p=(point*)(&x); cout << (*p).name << endl; 0x20eec 0x67 0x89 0x12 0x34 0xffbff5fc output: g 33

34 Coding Exampls Let s see some code Assigning and passing variables by value Assigning and passing variables by references Assigning and passing pointers Displaying the addresses of variables Debuggers gdb (see quick summary on next slide) ddd (on aludra and nunki) 34

35 The debugger is your friend! Get to know it! compile program with: -g start debugging: gdb hw1 set breakpoint: (gdb) break foo.c:123 run program: (gdb) run clear breakpoint: (gdb) clear stack trace: (gdb) where print field: (gdb) print f.blocktype printf(): (gdb) printf "%02x\n",buf[0] single-step at same level: (gdb) next single-step into a function: (gdb) step print field after every cmd: (gdb) display f.blocktype assignment: (gdb) set f.blocktype=0 continue: (gdb) cont quit: (gdb) quit Notes on gdb 35

36 CS102 Extra Slides Bill Cheng 36

37 variables.cpp /* * 1) Demonstrate static, stack, heap variables. * 2) Declare a static int. * 3) Write a function that returns the square of a number. * 4) In main(), use a stack variable, call square() and print * the number and its square. Call malloc() to create an * integer, call square() and print the number and its square. * 5) Use gdb to look at the addresses. */ 37

38 #include <iostream> using namespace std; static int z=3; int Square(int x) return x*x; variables.cpp int main(int argc, char *argv[]) int x = 17; cout << "Square(" << x << ") = " << Square(x) << endl; int *y = new int(29); cout << "Square(" << *y << ") = " << Square(*y) << endl; delete y; return 0; 38

39 memory.cpp /* * 1) Demonstrate memory management, static, stack, heap * variables. * 2) Define a struct Point with 3 fields: ch, x, y * 3) Declare a static Point. * 4) In main(), declare a Point in the stack. * Assign values to the fields of the stack variable. * Assign values to the fields of the static variable. * Allocate a pointer in the heap. * Assign values to the fields of the dynamic variable. * 5) Use gdb to look at the addresses. */ 39

40 #include <iostream> using namespace std; struct Point char name; int x; int y; ; static Point pt2; memory.cpp int main() Point pt1; pt1.name = 1 ; pt1.x = 123; pt1.y = 456; pt2.name = s ; pt2.x = 0x734; pt2.y = 0x1234; Point *pt3 = (Point*)malloc( sizeof(point)); if (pt3!= (Point*)0) pt3->name = d ; pt3->x = 0x97531; pt3->y = 0x24680; 40

41 values.cpp /* * 1) Demonstrate pass by value semantics. * 2) Write a function that takes in a single integer by value, * prints out its value and address. Keep in mind that "a" * is a COPY of the value that was passed in. * * Don t return a value from this function and see what * happens. * 3) In main(), prints "x" and its address; calls foo(); print * the value returned by foo(); prints "x" and its address * again and see if they have been changed. */ 41

42 #include <iostream> using namespace std; int foo(int a) a += 1; values.cpp cout << a << endl; cout << &a << endl; int main() int x = 5; cout << x << endl; cout << &x << endl; int f = foo(x); cout << "Foo = " << f << endl; cout << x << endl; 42

43 ref.cpp /* * 1) Demonstrate pass by reference semantics. * 2) Write a function that takes in a single integer by * reference, increment "a" by 1 and prints out its value * and address. * * Keep in mind that "a" refers to the same integer as the * caller of foo(). This function returns void. * 3) In main(), prints "x" and its address; calls foo(); * prints "x" again and see if they have been changed. * 4) Add a function to show that we can use pass by reference * to return multiple values from a function. For example, * returns the sum and the average of two integers. * (Is there another way to return multiple values from a * function?) * 5) Show that we can return a reference from a function. * Why is this a bad idea? */ 43

44 #include <iostream> using namespace std; void foo(int& a) a += 1; cout << a << endl; cout << &a << endl; void stats(int a, int b, int &sum, int &avg) sum = a + b; avg = (a + b)/2; int& bar(int a) int c = a + a; return c; ref.cpp int main() int x = 5; cout << x << endl; cout << &x << endl; foo(x); cout << x << endl; int a1 = 123; int a2 = 234; int sum = 0; int avg = 0; stats(a1,a2,sum,avg); int val = 123; int& valref = bar(val); cout << valref << endl; int& xref = x; cout << "xref = " << xref << endl; xref = 22222; cout << x << endl; cout << &x << endl; cout << &xref << endl; 44

45 pointers.cpp /* * 1) Demonstrate pass by pointer semantics. * 2) Write a function that takes in a pointer to an integer, * increment "a" by 1 and prints out its value and address. * Keep in mind that "a" points to the same memory * location as the integer passed by the caller of foo(). * This function returns void. * 3) In main(), prints "x" and its address; calls foo(); * prints "x" again and see if they have been changed. * 4) Shows that, unlike a reference, a single pointer can * be used to point to multiple different values. * 5) Shows that multiple pointers can point to the same value. */ 45

46 #include <iostream> using namespace std; void foo(int* a) (*a) += 1; cout << "a = " << a << endl; pointers.cpp int main() int x = 5; cout << "x = " << x << endl; foo(&x); cout << "x = " << x << endl; x = 5; int* ptr = &x; *ptr = 22222; cout << x << endl; cout << *ptr << endl; cout << &x << endl; cout << ptr << endl; int y = 10; int z = 15; int* newptr = &y; newptr = &z; int w = 22; int* p1 = &w; int* p2 = &w; 46

Lab 8. Follow along with your TA as they demo GDB. Make sure you understand all of the commands, how and when to use them.

Lab 8. Follow along with your TA as they demo GDB. Make sure you understand all of the commands, how and when to use them. Lab 8 Each lab will begin with a recap of last lab and a brief demonstration by the TAs for the core concepts examined in this lab. As such, this document will not serve to tell you everything the TAs

More information

CSCI 102L - Data Structures Midterm Exam #1 Fall 2011

CSCI 102L - Data Structures Midterm Exam #1 Fall 2011 Print Your Name: Page 1 of 8 Signature: Aludra Loginname: CSCI 102L - Data Structures Midterm Exam #1 Fall 2011 (10:00am - 11:12am, Wednesday, October 5) Instructor: Bill Cheng Problems Problem #1 (24

More information

CS C Primer. Tyler Szepesi. January 16, 2013

CS C Primer. Tyler Szepesi. January 16, 2013 January 16, 2013 Topics 1 Why C? 2 Data Types 3 Memory 4 Files 5 Endianness 6 Resources Why C? C is exteremely flexible and gives control to the programmer Allows users to break rigid rules, which are

More information

QUIZ. What are 3 differences between C and C++ const variables?

QUIZ. What are 3 differences between C and C++ const variables? QUIZ What are 3 differences between C and C++ const variables? Solution QUIZ Source: http://stackoverflow.com/questions/17349387/scope-of-macros-in-c Solution The C/C++ preprocessor substitutes mechanically,

More information

ECE 15B COMPUTER ORGANIZATION

ECE 15B COMPUTER ORGANIZATION ECE 15B COMPUTER ORGANIZATION Lecture 13 Strings, Lists & Stacks Announcements HW #3 Due next Friday, May 15 at 5:00 PM in HFH Project #2 Due May 29 at 5:00 PM Project #3 Assigned next Thursday, May 19

More information

pointers + memory double x; string a; int x; main overhead int y; main overhead

pointers + memory double x; string a; int x; main overhead int y; main overhead pointers + memory computer have memory to store data. every program gets a piece of it to use as we create and use more variables, more space is allocated to a program memory int x; double x; string a;

More information

CS 31: Intro to Systems Pointers and Memory. Martin Gagne Swarthmore College February 16, 2016

CS 31: Intro to Systems Pointers and Memory. Martin Gagne Swarthmore College February 16, 2016 CS 31: Intro to Systems Pointers and Memory Martin Gagne Swarthmore College February 16, 2016 So we declared a pointer How do we make it point to something? 1. Assign it the address of an existing variable

More information

C++ for Java Programmers

C++ for Java Programmers Basics all Finished! Everything we have covered so far: Lecture 5 Operators Variables Arrays Null Terminated Strings Structs Functions 1 2 45 mins of pure fun Introduction Today: Pointers Pointers Even

More information

C Review. MaxMSP Developers Workshop Summer 2009 CNMAT

C Review. MaxMSP Developers Workshop Summer 2009 CNMAT C Review MaxMSP Developers Workshop Summer 2009 CNMAT C Syntax Program control (loops, branches): Function calls Math: +, -, *, /, ++, -- Variables, types, structures, assignment Pointers and memory (***

More information

Section Notes - Week 1 (9/17)

Section Notes - Week 1 (9/17) Section Notes - Week 1 (9/17) Why do we need to learn bits and bitwise arithmetic? Since this class is about learning about how computers work. For most of the rest of the semester, you do not have to

More information

Practical Malware Analysis

Practical Malware Analysis Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the

More information

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

CSci 4061 Introduction to Operating Systems. Programs in C/Unix CSci 4061 Introduction to Operating Systems Programs in C/Unix Today Basic C programming Follow on to recitation Structure of a C program A C program consists of a collection of C functions, structs, arrays,

More information

CS 31: Intro to Systems Pointers and Memory. Kevin Webb Swarthmore College October 2, 2018

CS 31: Intro to Systems Pointers and Memory. Kevin Webb Swarthmore College October 2, 2018 CS 31: Intro to Systems Pointers and Memory Kevin Webb Swarthmore College October 2, 2018 Overview How to reference the location of a variable in memory Where variables are placed in memory How to make

More information

Pointers, Dynamic Data, and Reference Types

Pointers, Dynamic Data, and Reference Types Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation The new operator The delete operator Dynamic Memory Allocation for Arrays 1 C++ Data Types simple

More information

LAB #8. GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:

LAB #8. GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act: LAB #8 Each lab will begin with a brief demonstration by the TAs for the core concepts examined in this lab. As such, this document will not serve to tell you everything the TAs will in the demo. It is

More information

Programming Studio #9 ECE 190

Programming Studio #9 ECE 190 Programming Studio #9 ECE 190 Programming Studio #9 Concepts: Functions review 2D Arrays GDB Announcements EXAM 3 CONFLICT REQUESTS, ON COMPASS, DUE THIS MONDAY 5PM. NO EXTENSIONS, NO EXCEPTIONS. Functions

More information

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF

More information

Review: C Strings. A string in C is just an array of characters. Lecture #4 C Strings, Arrays, & Malloc

Review: C Strings. A string in C is just an array of characters. Lecture #4 C Strings, Arrays, & Malloc CS61C L4 C Pointers (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #4 C Strings, Arrays, & Malloc Albert Chae Instructor 2008-06-26 Review: C Strings A string in C is just an array

More information

Week 5, continued. This is CS50. Harvard University. Fall Cheng Gong

Week 5, continued. This is CS50. Harvard University. Fall Cheng Gong This is CS50. Harvard University. Fall 2014. Cheng Gong Table of Contents News... 1 Buffer Overflow... 1 Malloc... 6 Linked Lists... 7 Searching... 13 Inserting... 16 Removing... 19 News Good news everyone!

More information

Ch 4. Parameters and Function Overloading

Ch 4. Parameters and Function Overloading 2014-1 Ch 4. Parameters and Function Overloading March 19, 2014 Advanced Networking Technology Lab. (YU-ANTL) Dept. of Information & Comm. Eng, Graduate School, Yeungnam University, KOREA (Tel : +82-53-810-2497;

More information

Lecture 2, September 4

Lecture 2, September 4 Lecture 2, September 4 Intro to C/C++ Instructor: Prashant Shenoy, TA: Shashi Singh 1 Introduction C++ is an object-oriented language and is one of the most frequently used languages for development due

More information

CS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/

CS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/ CS61C Machine Structures Lecture 4 C Pointers and Arrays 1/25/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L04 C Pointers (1) Common C Error There is a difference

More information

LAB #8. Last Survey, I promise!!! Please fill out this really quick survey about paired programming and information about your declared major and CS.

LAB #8. Last Survey, I promise!!! Please fill out this really quick survey about paired programming and information about your declared major and CS. LAB #8 Each lab will begin with a brief demonstration by the TAs for the core concepts examined in this lab. As such, this document will not serve to tell you everything the TAs will in the demo. It is

More information

Chapter 1 Getting Started

Chapter 1 Getting Started Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different

More information

Class Information ANNOUCEMENTS

Class Information ANNOUCEMENTS Class Information ANNOUCEMENTS Third homework due TODAY at 11:59pm. Extension? First project has been posted, due Monday October 23, 11:59pm. Midterm exam: Friday, October 27, in class. Don t forget to

More information

Memory Management. a C view. Dr Alun Moon KF5010. Computer Science. Dr Alun Moon (Computer Science) Memory Management KF / 24

Memory Management. a C view. Dr Alun Moon KF5010. Computer Science. Dr Alun Moon (Computer Science) Memory Management KF / 24 Memory Management a C view Dr Alun Moon Computer Science KF5010 Dr Alun Moon (Computer Science) Memory Management KF5010 1 / 24 The Von Neumann model Memory Architecture One continuous address space Program

More information

arrays review arrays and memory arrays: character array example cis15 advanced programming techniques, using c++ summer 2008 lecture # V.

arrays review arrays and memory arrays: character array example cis15 advanced programming techniques, using c++ summer 2008 lecture # V. topics: arrays pointers arrays of objects resources: cis15 advanced programming techniques, using c++ summer 2008 lecture # V.1 some of this lecture is covered in parts of Pohl, chapter 3 arrays review

More information

CPS 104 Computer Organization and Programming

CPS 104 Computer Organization and Programming CPS 104 Computer Organization and Programming Lecture-3 : Memory, Bit Operations. Sep. 3, 1999 Dietolf (Dee) Ramm http://www.cs.duke.edu/~dr/cps104.html CPS104 Lec3.1 GK&DR Fall 1999 Administrivia Homework

More information

Lecture 14. No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions?

Lecture 14. No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions? Lecture 14 No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions? Friday, February 11 CS 215 Fundamentals of Programming II - Lecture 14 1 Outline Static

More information

Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics

More information

Arrays and Memory Management

Arrays and Memory Management Arrays and Memory Management 1 Pointing to Different Size Objects Modern machines are byte-addressable Hardware s memory composed of 8-bit storage cells, each has a unique address A C pointer is just abstracted

More information

Heap Arrays. Steven R. Bagley

Heap Arrays. Steven R. Bagley Heap Arrays Steven R. Bagley Recap Data is stored in variables Can be accessed by the variable name Or in an array, accessed by name and index a[42] = 35; Variables and arrays have a type int, char, double,

More information

CS24 Week 2 Lecture 1

CS24 Week 2 Lecture 1 CS24 Week 2 Lecture 1 Kyle Dewey Overview C Review Void pointers Allocation structs void* (Void Pointers) void* Like any other pointer, it refers to some memory address However, it has no associated type,

More information

Intermediate Programming, Spring 2017*

Intermediate Programming, Spring 2017* 600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general

More information

CS 61C: Great Ideas in Computer Architecture. C Arrays, Strings, More Pointers

CS 61C: Great Ideas in Computer Architecture. C Arrays, Strings, More Pointers CS 61C: Great Ideas in Computer Architecture C Arrays, Strings, More Pointers Instructor: Justin Hsia 6/20/2012 Summer 2012 Lecture #3 1 Review of Last Lecture C Basics Variables, Functions, Flow Control,

More information

377 Student Guide to C++

377 Student Guide to C++ 377 Student Guide to C++ c Mark Corner January 21, 2004 1 Introduction In this course you will be using the C++ language to complete several programming assignments. Up to this point we have only provided

More information

HW1 due Monday by 9:30am Assignment online, submission details to come

HW1 due Monday by 9:30am Assignment online, submission details to come inst.eecs.berkeley.edu/~cs61c CS61CL : Machine Structures Lecture #2 - C Pointers and Arrays Administrivia Buggy Start Lab schedule, lab machines, HW0 due tomorrow in lab 2009-06-24 HW1 due Monday by 9:30am

More information

CS3157: Advanced Programming. Outline

CS3157: Advanced Programming. Outline CS3157: Advanced Programming Lecture #12 Apr 3 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline Intro CPP Boring stuff: Language basics: identifiers, data types, operators, type conversions, branching

More information

Pointers & Dynamic Memory Review C Pointers Introduce C++ Pointers

Pointers & Dynamic Memory Review C Pointers Introduce C++ Pointers Pointers & Dynamic Memory Review C Pointers Introduce C++ Pointers Data Abstractions CSCI-2320 Dr. Tom Hicks Computer Science Department c http://carme.cs.trinity.edu/ thicks/2320/schedule.html http://carme.cs.trinity.edu/thicks/2320/schedule.html

More information

CS24 Week 3 Lecture 1

CS24 Week 3 Lecture 1 CS24 Week 3 Lecture 1 Kyle Dewey Overview Some minor C++ points ADT Review Object-oriented Programming C++ Classes Constructors Destructors More minor Points (if time) Key Minor Points const Motivation

More information

CS61 Lecture II: Data Representation! with Ruth Fong, Stephen Turban and Evan Gastman! Abstract Machines vs. Real Machines!

CS61 Lecture II: Data Representation! with Ruth Fong, Stephen Turban and Evan Gastman! Abstract Machines vs. Real Machines! CS61 Lecture II: Data Representation with Ruth Fong, Stephen Turban and Evan Gastman Abstract Machines vs. Real Machines Abstract machine refers to the meaning of a program in a high level language (i.e.

More information

CS61, Fall 2012 Section 2 Notes

CS61, Fall 2012 Section 2 Notes CS61, Fall 2012 Section 2 Notes (Week of 9/24-9/28) 0. Get source code for section [optional] 1: Variable Duration 2: Memory Errors Common Errors with memory and pointers Valgrind + GDB Common Memory Errors

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 4 C Pointers 2004-09-08 Lecturer PSOE Dan Garcia www.cs.berkeley.edu/~ddgarcia Cal flies over Air Force We re ranked 13 th in the US and

More information

THE GOOD, BAD AND UGLY ABOUT POINTERS. Problem Solving with Computers-I

THE GOOD, BAD AND UGLY ABOUT POINTERS. Problem Solving with Computers-I THE GOOD, BAD AND UGLY ABOUT POINTERS Problem Solving with Computers-I The good: Pointers pass data around efficiently Pointers and arrays 100 104 108 112 116 ar 20 30 50 80 90 ar is like a pointer to

More information

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated CNIT 127: Exploit Development Ch 1: Before you begin Updated 1-14-16 Basic Concepts Vulnerability A flaw in a system that allows an attacker to do something the designer did not intend, such as Denial

More information

CS103L FALL 2017 UNIT 1: TYPES, VARIABLES,EXPRESSIONS,C++ BASICS

CS103L FALL 2017 UNIT 1: TYPES, VARIABLES,EXPRESSIONS,C++ BASICS CS103L FALL 2017 UNIT 1: TYPES, VARIABLES,EXPRESSIONS,C++ BASICS LOGISTICS Homework due tonight and Thursday Should be able to do after reading textbook - go to TA/CP office hours Do the lab Go to lab

More information

CS2141 Software Development using C/C++ C++ Basics

CS2141 Software Development using C/C++ C++ Basics CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 4 Introduction to C (pt 2) 2014-09-08!!!Senior Lecturer SOE Dan Garcia!!!www.cs.berkeley.edu/~ddgarcia! C most popular! TIOBE programming

More information

Agenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011

Agenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011 CS 61C: Great Ideas in Computer Architecture (Machine Structures) Introduction to C (Part II) Instructors: Randy H. Katz David A. Patterson http://inst.eecs.berkeley.edu/~cs61c/sp11 Spring 2011 -- Lecture

More information

ECE 250 / CS 250 Computer Architecture. C to Binary: Memory & Data Representations. Benjamin Lee

ECE 250 / CS 250 Computer Architecture. C to Binary: Memory & Data Representations. Benjamin Lee ECE 250 / CS 250 Computer Architecture C to Binary: Memory & Data Representations Benjamin Lee Slides based on those from Alvin Lebeck, Daniel Sorin, Andrew Hilton, Amir Roth, Gershon Kedem Administrivia

More information

CS 240 Data Structure Spring 2018 Exam I 03/01/2018

CS 240 Data Structure Spring 2018 Exam I 03/01/2018 CS 240 Data Structure Spring 2018 Exam I 03/01/2018 This exam contains three section A) Code: (basic data type, pointer, ADT) a. Reading: Trace the code to predict the output of the code b. Filling: Fill

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #3 C Strings, Arrays, & Malloc 2007-06-27 Scott Beamer, Instructor Sun announces new supercomputer: Sun Constellation CS61C L3 C Pointers

More information

EL2310 Scientific Programming

EL2310 Scientific Programming Lecture 11: Structures and Memory (yaseminb@kth.se) Overview Overview Lecture 11: Structures and Memory Structures Continued Memory Allocation Lecture 11: Structures and Memory Structures Continued Memory

More information

#include <iostream> #include <algorithm> #include <cmath> using namespace std; int f1(int x, int y) { return (double)(x/y); }

#include <iostream> #include <algorithm> #include <cmath> using namespace std; int f1(int x, int y) { return (double)(x/y); } 1. (9 pts) Show what will be output by the cout s in this program. As in normal program execution, any update to a variable should affect the next statement. (Note: boolalpha simply causes Booleans to

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #4 C Memory Management 2007-06-28 Scott Beamer, Instructor iphone Comes out Tomorrow CS61C L4 C Memory Management (1) www.apple.com/iphone

More information

CS 11 C track: lecture 6

CS 11 C track: lecture 6 CS 11 C track: lecture 6 Last week: pointer arithmetic This week: The gdb program struct typedef linked lists gdb for debugging (1) gdb: the Gnu DeBugger http://courses.cms.caltech.edu/cs11/material /c/mike/misc/gdb.html

More information

Announcements. CSCI 334: Principles of Programming Languages. Lecture 18: C/C++ Announcements. Announcements. Instructor: Dan Barowy

Announcements. CSCI 334: Principles of Programming Languages. Lecture 18: C/C++ Announcements. Announcements. Instructor: Dan Barowy CSCI 334: Principles of Programming Languages Lecture 18: C/C++ Homework help session will be tomorrow from 7-9pm in Schow 030A instead of on Thursday. Instructor: Dan Barowy HW6 and HW7 solutions We only

More information

A506 / C201 Computer Programming II Placement Exam Sample Questions. For each of the following, choose the most appropriate answer (2pts each).

A506 / C201 Computer Programming II Placement Exam Sample Questions. For each of the following, choose the most appropriate answer (2pts each). A506 / C201 Computer Programming II Placement Exam Sample Questions For each of the following, choose the most appropriate answer (2pts each). 1. Which of the following functions is causing a temporary

More information

High-performance computing and programming Intro to C on Unix/Linux. Uppsala universitet

High-performance computing and programming Intro to C on Unix/Linux. Uppsala universitet High-performance computing and programming Intro to C on Unix/Linux IT Uppsala universitet What is C? An old imperative language that remains rooted close to the hardware C is relatively small and easy

More information

When you add a number to a pointer, that number is added, but first it is multiplied by the sizeof the type the pointer points to.

When you add a number to a pointer, that number is added, but first it is multiplied by the sizeof the type the pointer points to. Refresher When you add a number to a pointer, that number is added, but first it is multiplied by the sizeof the type the pointer points to. i.e. char *ptr1 = malloc(1); ptr1 + 1; // adds 1 to pointer

More information

Lab#5 Due Wednesday, February 25, at the start of class. Purpose: To develop familiarity with C++ pointer variables

Lab#5 Due Wednesday, February 25, at the start of class. Purpose: To develop familiarity with C++ pointer variables Lab#5 Due Wednesday, February 25, at the start of class Purpose: To develop familiarity with C++ pointer variables Introduction: In this lab, you will learn by experimentation the answers to some questions

More information

Review! * follows a pointer to its value! & gets the address of a variable! Pearce, Summer 2010 UCB! ! int x = 1000; Pearce, Summer 2010 UCB!

Review! * follows a pointer to its value! & gets the address of a variable! Pearce, Summer 2010 UCB! ! int x = 1000; Pearce, Summer 2010 UCB! CS61C L03 Introduction to C (pt 2) (1)! inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 3 Introduction to C (pt 2) 2010-06-23!!!Instructor Paul Pearce! The typical! development cycle!

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 3 Introduction to C (pt 2) 2010-06-23! C help session: Tonight 7:00-9:00pm @ 306 Soda!!!Instructor Paul Pearce! The typical! development

More information

ALL ABOUT POINTERS C/C++ POINTERS

ALL ABOUT POINTERS C/C++ POINTERS ALL ABOUT POINTERS CS 403: Pointers, References, and Management Stefan D. Bruda Fall 2017 http://xkcd.com/138/ CS 403: Pointers, References, and Management (S. D. Bruda) Fall 2017 1 / 27 POINTERS C/C++

More information

CSCI 104 Memory Allocation. Mark Redekopp David Kempe

CSCI 104 Memory Allocation. Mark Redekopp David Kempe CSCI 104 Memory Allocation Mark Redekopp David Kempe VARIABLES & SCOPE 2 A Program View of Memory Code usually sits at low addresses Global variables somewhere after code System stack (memory for each

More information

COSC345 Software Engineering. Basic Computer Architecture and The Stack

COSC345 Software Engineering. Basic Computer Architecture and The Stack COSC345 Software Engineering Basic Computer Architecture and The Stack Outline Architectural models A little about the 68HC11 Memory map Registers A little bit of assembly (never did us any harm) The program

More information

CS2141 Software Development using C/C++ Debugging

CS2141 Software Development using C/C++ Debugging CS2141 Software Development using C/C++ Debugging Debugging Tips Examine the most recent change Error likely in, or exposed by, code most recently added Developing code incrementally and testing along

More information

int n = 10; int sum = 10; while (n > 1) { sum = sum + n; n--; } cout << "The sum of the integers 1 to 10 is " << sum << endl;

int n = 10; int sum = 10; while (n > 1) { sum = sum + n; n--; } cout << The sum of the integers 1 to 10 is  << sum << endl; Debugging Some have said that any monkey can write a program the hard part is debugging it. While this is somewhat oversimplifying the difficult process of writing a program, it is sometimes more time

More information

Pointers and Arrays 1

Pointers and Arrays 1 Pointers and Arrays 1 Pointers and Arrays When an array is declared, The compiler allocates sufficient amount of storage to contain all the elements of the array in contiguous memory locations The base

More information

Getting started with C++ (Part 2)

Getting started with C++ (Part 2) Getting started with C++ (Part 2) CS427: Elements of Software Engineering Lecture 2.2 11am, 16 Jan 2012 CS427 Getting started with C++ (Part 2) 1/22 Outline 1 Recall from last week... 2 Recall: Output

More information

CSCI-1200 Data Structures Spring 2016 Lecture 6 Pointers & Dynamic Memory

CSCI-1200 Data Structures Spring 2016 Lecture 6 Pointers & Dynamic Memory Announcements CSCI-1200 Data Structures Spring 2016 Lecture 6 Pointers & Dynamic Memory There will be no lecture on Tuesday, Feb. 16. Prof. Thompson s office hours are canceled for Monday, Feb. 15. Prof.

More information

CS107 Handout 08 Spring 2007 April 9, 2007 The Ins and Outs of C Arrays

CS107 Handout 08 Spring 2007 April 9, 2007 The Ins and Outs of C Arrays CS107 Handout 08 Spring 2007 April 9, 2007 The Ins and Outs of C Arrays C Arrays This handout was written by Nick Parlante and Julie Zelenski. As you recall, a C array is formed by laying out all the elements

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Fall 2018 Discussion 2: September 3, 2018

Fall 2018 Discussion 2: September 3, 2018 CS 61C C Basics Fall 2018 Discussion 2: September 3, 2018 1 C C is syntactically similar to Java, but there are a few key differences: 1. C is function-oriented, not object-oriented; there are no objects.

More information

Heap Arrays and Linked Lists. Steven R. Bagley

Heap Arrays and Linked Lists. Steven R. Bagley Heap Arrays and Linked Lists Steven R. Bagley Recap Data is stored in variables Can be accessed by the variable name Or in an array, accessed by name and index Variables and arrays have a type Create our

More information

CSE au Midterm Exam Nov. 2, 2018 Sample Solution

CSE au Midterm Exam Nov. 2, 2018 Sample Solution Question 1. (16 points) Build tools and make. We re building a C++ software back-end prototype for a new food web site. So far, we ve got the following source files with the code for two main programs

More information

CS 103 Unit 13 Slides

CS 103 Unit 13 Slides 1 CS 103 Unit 13 Slides C++ References Mark Redekopp 2 Swap Two Variables Classic example of issues with local variables: Write a function to swap two variables Pass-b-value doesn t work Cop is made of

More information

Final Exam. 11 May 2018, 120 minutes, 26 questions, 100 points

Final Exam. 11 May 2018, 120 minutes, 26 questions, 100 points Name: CS520 Final Exam 11 May 2018, 120 minutes, 26 questions, 100 points The exam is closed book and notes. Please keep all electronic devices turned off and out of reach. Note that a question may require

More information

CS31 Discussion 1E Spring 17 : week 08

CS31 Discussion 1E Spring 17 : week 08 CS31 Discussion 1E Spring 17 : week 08 TA: Bo-Jhang Ho bojhang@cs.ucla.edu Credit to former TA Chelsea Ju Project 5 - Map cipher to crib Approach 1: For each pair of positions, check two letters in cipher

More information

CS61C Machine Structures. Lecture 5 C Structs & Memory Mangement. 1/27/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/

CS61C Machine Structures. Lecture 5 C Structs & Memory Mangement. 1/27/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/ CS61C Machine Structures Lecture 5 C Structs & Memory Mangement 1/27/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L05 C Structs (1) C String Standard Functions

More information

unsigned char memory[] STACK ¼ 0x xC of address space globals function KERNEL code local variables

unsigned char memory[] STACK ¼ 0x xC of address space globals function KERNEL code local variables Graded assignment 0 will be handed out in section Assignment 1 Not that bad Check your work (run it through the compiler) Factorial Program Prints out ENTERING, LEAVING, and other pointers unsigned char

More information

QUIZ. Source:

QUIZ. Source: QUIZ Source: http://stackoverflow.com/questions/17349387/scope-of-macros-in-c Ch. 4: Data Abstraction The only way to get massive increases in productivity is to leverage off other people s code. That

More information

CS 322 Operating Systems Practice Midterm Questions

CS 322 Operating Systems Practice Midterm Questions ! CS 322 Operating Systems 1. Processes go through the following states in their lifetime. time slice ends Consider the following events and answer the questions that follow. Assume there are 5 processes,

More information

Kurt Schmidt. October 30, 2018

Kurt Schmidt. October 30, 2018 to Structs Dept. of Computer Science, Drexel University October 30, 2018 Array Objectives to Structs Intended audience: Student who has working knowledge of Python To gain some experience with a statically-typed

More information

a data type is Types

a data type is Types Pointers Class 2 a data type is Types Types a data type is a set of values a set of operations defined on those values in C++ (and most languages) there are two flavors of types primitive or fundamental

More information

Comp 11 Lectures. Mike Shah. June 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures June 26, / 57

Comp 11 Lectures. Mike Shah. June 26, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures June 26, / 57 Comp 11 Lectures Mike Shah Tufts University June 26, 2017 Mike Shah (Tufts University) Comp 11 Lectures June 26, 2017 1 / 57 Please do not distribute or host these slides without prior permission. Mike

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

CS 392/681 Lab 6 Experiencing Buffer Overflows and Format String Vulnerabilities

CS 392/681 Lab 6 Experiencing Buffer Overflows and Format String Vulnerabilities CS 392/681 Lab 6 Experiencing Buffer Overflows and Format String Vulnerabilities Given: November 13, 2003 Due: November 20, 2003 1 Motivation Buffer overflows and format string vulnerabilities are widespread

More information

Lecture 04 Introduction to pointers

Lecture 04 Introduction to pointers Lecture 04 Introduction to pointers A pointer is an address in the memory. One of the unique advantages of using C is that it provides direct access to a memory location through its address. A variable

More information

CS 61C: Great Ideas in Computer Architecture C Pointers. Instructors: Vladimir Stojanovic & Nicholas Weaver

CS 61C: Great Ideas in Computer Architecture C Pointers. Instructors: Vladimir Stojanovic & Nicholas Weaver CS 61C: Great Ideas in Computer Architecture C Pointers Instructors: Vladimir Stojanovic & Nicholas Weaver http://inst.eecs.berkeley.edu/~cs61c/sp16 1 Agenda Pointers Arrays in C 2 Address vs. Value Consider

More information

Principles of Programming Pointers, Dynamic Memory Allocation, Character Arrays, and Buffer Overruns

Principles of Programming Pointers, Dynamic Memory Allocation, Character Arrays, and Buffer Overruns Pointers, Dynamic Memory Allocation, Character Arrays, and Buffer Overruns What is an array? Pointers Memory issues The name of the array is actually a memory address. You can prove this by trying to print

More information

Lectures 13 & 14. memory management

Lectures 13 & 14. memory management Lectures 13 & 14 Linked lists and memory management Courtesy of Prof. Garcia (UCB) CS61C L05 Introduction to C (pt 3) (1) Review Pointers and arrays are virtually same C knows how to increment pointers

More information

More C Pointer Dangers

More C Pointer Dangers CS61C L04 Introduction to C (pt 2) (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Must-see talk Thu 4-5pm @ Sibley by Turing Award winner Fran Allen: The Challenge of Multi-Cores: Think Sequential,

More information

CS 107 Lecture 2: Bits and Bytes (continued)

CS 107 Lecture 2: Bits and Bytes (continued) CS 107 Lecture 2: Bits and Bytes (continued) Friday, January 12, 2018 Computer Systems Winter 2018 Stanford University Computer Science Department Reading: Reader: Number Formats Used in CS 107 and Bits

More information

Midterm Exam #2 Spring (1:00-3:00pm, Friday, March 15)

Midterm Exam #2 Spring (1:00-3:00pm, Friday, March 15) Print Your Name: Signature: USC email address: CSCI 101L Fundamentals of Computer Programming Midterm Exam #2 Spring 2013 (1:00-3:00pm, Friday, March 15) Instructor: Prof Tejada Problem #1 (20 points):

More information

a. a * c - 10 = b. a % b + (a * d) + 7 =

a. a * c - 10 = b. a % b + (a * d) + 7 = Exam #2 CISC1110, MW 10:35-12:40pm Fall 2011 Name 1 Evaluate each expression according to C++ rules (8 pts) Given: Integers a = 3, b = 2, c = 5, and float d = 40 a a * c - 10 = b a % b + (a * d) + 7 =

More information

CS 216 Fall 2007 Midterm 1 Page 1 of 10 Name: ID:

CS 216 Fall 2007 Midterm 1 Page 1 of 10 Name:  ID: Page 1 of 10 Name: Email ID: You MUST write your name and e-mail ID on EACH page and bubble in your userid at the bottom of EACH page including this page and page 10. If you do not do this, you will receive

More information

Survey. Motivation 29.5 / 40 class is required

Survey. Motivation 29.5 / 40 class is required Survey Motivation 29.5 / 40 class is required Concerns 6 / 40 not good at examination That s why we have 3 examinations 6 / 40 this class sounds difficult 8 / 40 understand the instructor Want class to

More information

EECS402 Lecture 02. Functions. Function Prototype

EECS402 Lecture 02. Functions. Function Prototype The University Of Michigan Lecture 02 Andrew M. Morgan Savitch Ch. 3-4 Functions Value and Reference Parameters Andrew M. Morgan 1 Functions Allows for modular programming Write the function once, call

More information

Homework #3 CS2255 Fall 2012

Homework #3 CS2255 Fall 2012 Homework #3 CS2255 Fall 2012 MULTIPLE CHOICE 1. The, also known as the address operator, returns the memory address of a variable. a. asterisk ( * ) b. ampersand ( & ) c. percent sign (%) d. exclamation

More information