Puzzle DA1


Print each element in an array of ints, one per line

[E-6] Write a subroutine void printArray( int arr[], int size ) that prints the elements of an integer array one per line. Write a main() program that declares an array and prints it out using the function. Here is some typical output:

index   value
-----   -----
   0:       0
   1:       9
   2:      23
   3:      -6
   4:       5
   5:       2
   6:      71
   7:      45
   8:      -9
   9:       3

Here is a skeleton of the program. Your job is to finish it. Use copy-and-paste to copy this code into a source file.

#include <stdio.h>
#include <stdlib.h>

/* Puzzle D01 — print each element in an array of ints, one per line */

void printArray( int size, int arr[] )
{

}


int main(int argc, char *argv[])
{
  int x[] = {0, 9, 23, -6, 5, 2, 71, 45, -9, 3 };
  
  printArray( 10, x );
    
  printf("\n");
  system("pause"); /* remove this if desired */	
  return 0;
}


Answer         Next Page         Previous Page Home