int nums size
play

int nums[SIZE]; int i; for (i = 0; i < SIZE; i++) { nums[i] = i - PowerPoint PPT Presentation

int SIZE = 4; int nums[SIZE]; int i; for (i = 0; i < SIZE; i++) { nums[i] = i * i; } list = *1, spam, 4, U+ list.insert (2, soup) list.remove (spam) length = len(list) int


  1. int SIZE = 4; int nums[SIZE]; int i; for (i = 0; i < SIZE; i++) { nums[i] = i * i; }

  2. • • • • • • • •

  3. list = *1, “spam”, 4, “U”+ list.insert (2, “soup”) list.remove (“spam”) length = len(list)

  4. int main() { int SIZE = 7; int a[] = { 16, 5, 23, 19, 42, 17, 12 }; int evens = countEvens(a, SIZE); printf("The number of even numbers is %d.\n", evens); return 0 ; }

  5. int main() { int SIZE = 7; int a[] = { 16, 5, 23, 19, 42, 17, 12 }; int evens = countEvens(a, SIZE); printf("The number of even numbers is %d.\n", evens); int countEvens(int nums[], int size) { return 0 ; // Returns the count of even numbers in the nums array. } … return count; }

  6. int countEvens(int nums[], int size) { int count, i; count = 0; for (i = 0; i < size; i++) { int countEvens(int* nums, int size) if (nums[i] % 2 == 0) { count++; } } return count; }

  7. • • • –

Recommend


More recommend