Presentation is loading. Please wait.

Presentation is loading. Please wait.

Arrays & pointers C How to Program, 8/e.

Similar presentations


Presentation on theme: "Arrays & pointers C How to Program, 8/e."— Presentation transcript:

1 Arrays & pointers C How to Program, 8/e

2

3

4 How arrays work

5 How arrays work

6

7 Strings in C

8 Strlen and sizeof

9 Introducing pointers

10

11

12 Passing function arguments

13

14 What's the output of this code?

15

16

17 What happens when you run this?

18

19 Pointers VS Arrays

20 #include <stdio.h>
int largest(int* ,int); int largest(int* arr,int num) { int largest=*arr; int i; for (i=1;i<num;i++) // if (a[i] > largest) if (*(arr+i) > largest) //largest=arr[i]; largest=*(arr+i); } return largest; int main() int a[10]; for (i=0; i< 10; i++) printf("Enter a number: "); scanf("%d",&a[i]); // printf("The largest: %d\n",largest(&a[0],10)); printf("The largest: %d\n",largest(a,10)); return 0;


Download ppt "Arrays & pointers C How to Program, 8/e."

Similar presentations


Ads by Google