Puzzle 2D5

Fill an array with integers in ascending order

[E-4] Write a function that fills an array with integers in ascending order. Unlike puzzle D01, do the work in a function, not in main().

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

/* Puzzle D05 -- fill  an array with integers in ascending order */
#define COLS 7
#define ROWS 5

void print2DArray ( int nrows, int ncols, int x[nrows][ncols] )
{
}

void fill2DArray ( int nrows, int ncols, int x[nrows][ncols] )
{
}

int main()
{
  int x[ROWS][COLS] ;
  
  /* Fill the array with ascending integers */
  fill2DArray( ROWS, COLS, x );
      
  /* Print the array using our function */
  print2DArray( ROWS, COLS, x  );
  
  printf("\n");
  return 0;
}


Previous Page        Answer         Next Page         Home