Puzzle DA3


Fill an array by making each element the same integer x

[E-4] Write a function that fills an array by putting the same integer in each slot. Here is a testing framework:

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

/* Puzzle D03 - fill an array by making each element the same integer x */
void fillArrayConst( int size, int arr[], int x )
{
  ... fill in here ...
}

void printArray( int size, int arr[] )
{
  ... from above ...
}

const int SIZE = 100;
int main(int argc, char *argv[])
{
  int x[ SIZE ];
  
  fillArrayConst( SIZE, x, 7 );
  printArray( SIZE, x );
    
  printf("\n");
  return 0;
}


Answer         Next Page         Previous Page Home