CODE
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define MAX 10
#define MIN 5
/*function prototype*/
void initializeArray(int[][MAX]);
void printArray(int [][MAX]);
void populateRandomValues (int [][MAX],int, int);
void bubblesort(int [][MAX], int,int);
void main(void)
{
int array[MIN][MAX], temp, max, key;
int lower, upper= MAX*10;
initializeArray (array);
printArray (array);
populateRandomValues (array, lower, upper);
printArray (array);
bubblesort(array, temp,max);
printArray (array);
}
void printArray(int array[][MAX])
{
int r, c;
for(r=0;r<MIN;r++)
{
for(c=0;c<MAX;c++)
{
printf(" %d",array[r][c]);
}
printf("\n");
}
printf("\n");
}
void populateRandomValues (int array[][MAX],int lower, int upper)
{
int r,c;
srand(time(NULL));
for(r=0;r<MIN;r++)
{
for(c=0;c<MAX;c++)
{
array[r][c]=1+(rand()%100);
}
}
}void bubblesort(int array[][MAX], int temp,int max)
{
int r,k,c,z;
for(r=0;r<MAX;r++)
{
for(c=0;c<MAX-1;c++)
{
if(array[z][c] > array[z][c+1])
{
temp= array[z][c];
array[z][c]= array[z][c+1];
array[z][c+1]= temp;
}
if(c % (MAX-2) == 0)
{
for(z=0;z<MAX;z++)
{
if(array[r][c]>array[r+1][z])
{
temp = array[r][c];
array[r][c] = array[r+1][z];
array[r+1][z] = temp;
}
}
}
}
}
}
* mod edit - added code tags