Arrays & pointers C How to Program, 8/e
How arrays work
How arrays work
Strings in C
Strlen and sizeof
Introducing pointers
Passing function arguments
What's the output of this code?
What happens when you run this?
Pointers VS Arrays
#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;