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);

Slides:



Advertisements
Similar presentations
For(int i = 1; i
Advertisements

Test practice Multiplication. Multiplication 9x2.
Pointer to Structure. Structure variable can be access using pointers int a=10,*p; Here p  is an integer type pointer variable, p can hold the address.
Single Right rotation (compare to RotateWithLeftChild page 148 text) void rotateRight(AVLNode *& curr) { AVLNode * kid = curr->left; curr->left = kid->right;
By Senem Kumova Metin 1 POINTERS + ARRAYS + STRINGS REVIEW.
Pointers and Output Parameters. Pointers A pointer contains the address of another memory cell –i.e., it “points to” another variable cost:1024.
Topic 2 Pointers CSE1303 Part A, Summer Semester,2002 Data Structures and Algorithms.
1 CSE1301 Computer Programming Lecture 16 Pointers.
Chapter 10 More on Modular Programming and Functions.
1 CSE1301 Computer Programming Lecture 16 Pointers.
Computer Science 210 Computer Organization Pointers.
7. Pointers, Dynamic Memory 20 th September IIT Kanpur 1C Course, Programming club, Fall 2008.
6. More on Pointers 14 th September IIT Kanpur C Course, Programming club, Fall
C Programming Lecture 8-2 : Function (advanced). Recursive Function (recursion) A function that calls itself (in its definition) Classic example : factorial.
Week 6 - Wednesday.  What did we talk about last time?  Exam 1!  And before that…  Review!  And before that…  Arrays and strings.
1. Agenda for loop Short-handed notation How to use break and continue 2.
1 CSE1301 Computer Programming Lecture 12 Functions (Part 1)
CSE 251 Dr. Charles B. Owen Programming in C1 Pointers, Arrays, Multidimensional Arrays Pointers versus arrays – Lots of similarities How to deal with.
Lecture 4: Calculating by Iterating. The while Repetition Statement Repetition structure Programmer specifies an action to be repeated while some condition.
Tracing through E01, question 9 – step 1 // p02.cc P. Conrad, for CISC181 07S // Exam question for E01 #include using namespace std; void mysteryFunction(int.
Lecture 13: Working with Multiple Programmers. Headers Header files: Each standard library has a corresponding header. The function prototype for all.
Lecture 15: Projects Using Similar Data. What is an Array? An array is a data structure consisting of related data items of the same type. Stored in a.
Lecture 17: The Last Puzzle Piece with Functions.
Pointers Value, Address, and Pointer. Values and Addresses int x, y, z; y x z values of x,
Pointers and Arrays An array's name is a constant whose value is the address of the array's first element. For this reason, the value of an array's name.
Pointers PART - 2. Pointers Pointers are variables that contain memory addresses as their values. A variable name directly references a value. A pointer.
C programming---Pointers The first step: visualizing what pointers represent at the machine level. In most modern computers, main memory is divided into.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Array of pointers We can have an array whose members are pointers, in this example pointers-to-int. int* data[3]; int i; int x = 5; int y = 89; int z =
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.
Functions and Pointers Dr. Sajib Datta Oct 6, 2014.
Array Sort. Sort Pass 1 Sort Pass 2 Sort Pass 3.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Pointers Call-by-Reference.
Pointers (Revision). 2 Overview Revision of Pointers Pointers and structs Basic Pointer Arithmetic Pointers and Arrays.
Basic Concepts:- Invalid use of Address Operator &75 &(‘a’) &(a+b)
Arrays Name, Index, Address. Arrays – Declaration and Initialization int x; y[0] y[1] y[2]
Dynamic memory allocation and Intraprogram Communication.
Recursive. Recursive F(n) = F(n-1) + F(n-2) n! = (n-1)! x n C(m,n) = C(m-1,n-1)+C(m-1,n)......
CSC 215 Pointers and Arrays. Pointers C provides two unary operators, & and *, for manipulating data using pointers The operator &, when applied to a.
C Programming Lecture 8 Call by Reference Scope. Call-by-Reference b For a C function to “effect” (read as “imitate”) call-by- reference: Pointers must.
Chapter 8 Arrays, Strings and Pointers
Introduction to Programming Using C
CSE 220 – C Programming Pointers.
Functions and Pointers
Pointers and Pass By Reference
Static vs Dynamic Scope
Pointers.
CSI-121 Structured Programming Language Lecture 16 Pointers
Dynamic memory allocation and Intraprogram Communication
Functions and Pointers
INC 161 , CPE 100 Computer Programming
14th September IIT Kanpur
Pointers.
Lecture 18: The Elegant, Abstract World of Computing
Константе оператори Задаци....
Pointers  Week 10.
Pointers and dynamic memory
Pointers & Functions.
CSC215 Homework Homework 04 Due date: Oct 14, 2016.
Dynamic Memory A whole heap of fun….
ECE 103 Engineering Programming Chapter 32 Array Parameters
CSE 3302 Programming Languages
CSC215 Homework Homework 03 Due date: Oct 07, 2016.
Homework Finishing K&R Chapter 5 today Starting K&R Chapter 6 next
Simulating Reference Parameters in C
7. Pointers, Dynamic Memory
Chien-Chung Shen CIS/UD
Pointers & Functions.
The Stack.
컴퓨터 프로그래밍 기초 - 13th : 마지막 수업 -
Presentation transcript:

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); return 1; } x is a pointer to an int follow the pointer at x the address of y

Functions and Pointers Call-by-value void f( int x ) { x = 10; return; } #include int main() { int a = 5; f( a ); printf(“%d\n”, a); return 0; }

Functions and Pointers Call by reference –Multiple return values void f( int *x ) { *x = 10; return; } #include int main() { int a = 5; f( &a ); printf(“%d\n”, a); return 0; }