Your SlideShare is downloading. ×
C-15
C-15
C-15
C-15
C-15
C-15
C-15
C-15
C-15
C-15
C-15
C-15
C-15
C-15
C-15
C-15
C-15
C-15
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

C-15

83

Published on

Published in: Education, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
83
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Lecture 15Lecture 15 Version 1.0Version 1.0 Pointers and ArraysPointers and Arrays
  • 2. 2Rushdi Shams, Dept of CSE, KUET, Bangladesh Passing Array Elements to FunctionsPassing Array Elements to Functions  Array elements can be passed to a function byArray elements can be passed to a function by calling the function by value, or by referencecalling the function by value, or by reference  In the call by value we pass values of arrayIn the call by value we pass values of array elements to the functionelements to the function  in the call by reference we pass addresses ofin the call by reference we pass addresses of array elements to the functionarray elements to the function
  • 3. 3Rushdi Shams, Dept of CSE, KUET, Bangladesh Passing Array Elements toPassing Array Elements to Functions: Call by valueFunctions: Call by value
  • 4. 4Rushdi Shams, Dept of CSE, KUET, Bangladesh Passing Array Elements toPassing Array Elements to Functions: Call by referenceFunctions: Call by reference
  • 5. 5Rushdi Shams, Dept of CSE, KUET, Bangladesh Pointer ArithmeticPointer Arithmetic
  • 6. 6Rushdi Shams, Dept of CSE, KUET, Bangladesh Pointer ArithmeticPointer Arithmetic  Addition of a number to a pointerAddition of a number to a pointer
  • 7. 7Rushdi Shams, Dept of CSE, KUET, Bangladesh Pointer ArithmeticPointer Arithmetic  Subtraction of a number from a pointerSubtraction of a number from a pointer
  • 8. 8Rushdi Shams, Dept of CSE, KUET, Bangladesh What do we know so far?What do we know so far?  Array elements are always stored in contiguousArray elements are always stored in contiguous memory locations.memory locations.  A pointer when incremented always points to anA pointer when incremented always points to an immediately next location of its type.immediately next location of its type.
  • 9. 9Rushdi Shams, Dept of CSE, KUET, Bangladesh Pointers and ArraysPointers and Arrays
  • 10. 10Rushdi Shams, Dept of CSE, KUET, Bangladesh Pointer and ArrayPointer and Array  Our next two programs show ways in which weOur next two programs show ways in which we can access the elements of this array.can access the elements of this array.
  • 11. 11Rushdi Shams, Dept of CSE, KUET, Bangladesh Pointer and ArrayPointer and Array
  • 12. 12Rushdi Shams, Dept of CSE, KUET, Bangladesh Pointer and ArrayPointer and Array
  • 13. 13Rushdi Shams, Dept of CSE, KUET, Bangladesh Passing entire array to functionPassing entire array to function
  • 14. 14Rushdi Shams, Dept of CSE, KUET, Bangladesh Similar Statements!Similar Statements!
  • 15. 15Rushdi Shams, Dept of CSE, KUET, Bangladesh Array of PointersArray of Pointers  The way there can be an array ofThe way there can be an array of intints or an arrays or an array ofof floatfloats, similarly there can be an array ofs, similarly there can be an array of pointerspointers  an array of pointers would be nothing but aan array of pointers would be nothing but a collection of addressescollection of addresses
  • 16. 16Rushdi Shams, Dept of CSE, KUET, Bangladesh Array of pointersArray of pointers
  • 17. 17Rushdi Shams, Dept of CSE, KUET, Bangladesh Array of pointersArray of pointers
  • 18. 18Rushdi Shams, Dept of CSE, KUET, Bangladesh Pointers to arrayPointers to array  An array of pointers can even contain the addressesAn array of pointers can even contain the addresses of other arraysof other arrays

×