w9 - BIL104E INTRODUCTION TO SCIENTIFIC AND ENGINEERING...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
BIL104E INTRODUCTION TO SCIENTIFIC AND ENGINEERING COMPUTING (C) WEEK – 9
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Arrays and Pointers assign the address of the first element to the pointer variable: int *ptr_array; array1[9]; ptr_array = array1; ptr_array = &array1[0]; the address of the first element in the array1 is the beginning address of the array the pointer variable ptr_array is referencing the array via the beginning address. The expression array[n] is equivalent to the expression *(ptr_array + n) Start address of array1 MEMORY 2 3 4 5 6 7 8 9 0 1 MEMORY Assume n=4, and array[4]=6 *(ptr_array + 4)=6
Background image of page 2
Sorting array by using pointers Just like in sorting arrays. However in this situation, functions would be defined by pointers. Main function would be same Increased/decreased order function which includes for loop and if again. In for loop after if statement send the adresses of related elements to another function that spawn the elements Spawning function will take the adresses and use pointer declerations (*ptr) to spawn the elements.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/22/2010 for the course BIL 104 taught by Professor Abc during the Fall '09 term at Istanbul Technical University.

Page1 / 9

w9 - BIL104E INTRODUCTION TO SCIENTIFIC AND ENGINEERING...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online