1. ## Array dis-array :)

Hello All...

I've got a 2D Array that takes in inputs, each time the degree difficulty is to be scanned into the first slot of the Array..and then the scores added after that...
then I go on to get the max and the min..
Although it scans in the scores the difficulty gets ignored..
any ideas on where I have slipped up....Gratefully appreciated

Code:
```#include<stdio.h>

int main (void)
{

int i,j;//array subscripts
int counter=1;// this is my loop counter
int counter_2=1;//this counter prints out the dive number to the user
//this 2D Array holds the dive difficulty and the scores awarded by the five judges for diver 1
// NOTE the Degree of difficulty is held in the first slot of each Array Row
double murphy[6][3]; //Array declared and filled with zeros
double max=0;//variable for max score
double min=0;//variable for min score
// Program Splash Screen
printf("*****************************************************************************\n");
printf("*                                                                           *\n");
printf("* Welcome to Splash Down                                                    *\n");
printf("*                                                                           *\n");
printf("*    Enter Your Divers Details                                              *\n");
printf("*****************************************************************************\n");

//this for loop fills the array with zero's
for (i=0;i<6;i++)

for (j=0;j<3;j++)
{
murphy[i][j]=0;
}

/*These for loops scan the the data into the 2D Array
As our Array is like a matrix and we need two for loops to process
the Rows and columes of the Array*/

for(i=0;i<3;i++)

{
//Ask the user to enter the dive difficulty (1-4)
printf("Enter Degree of  Difficulty For Dive %d Diver 1 (1-4) >>",counter_2);
scanf("%lf",&murphy[i][j]);

for(j=1;j<6;j++)

{

//As the user to enter the 5 dive scores for diver 1
printf("Enter Judge %d score for dive %d ",counter,counter_2);
scanf("%lf",&murphy[i][j]);

counter+=1;

}
counter=1;//reset the judges counter to 1 after each loop
counter_2+=1;//add 1 to the divers dive counter

}
//Search the array and find the max score
for (i=0;i<3;i++)

for (j=0;j<6;j++)

if (murphy[i][j]>max)
{
max=murphy[i][j];
}

//Search the array and find the min score
for (i=0;i<3;i++)

for (j=0;j<6;j++)
// if we find a score less than max then assign it to min
if (murphy[i][j]<max)
{
min=murphy[i][j];
}

//this is just a test print to make sure the data in the array is in correct
for(i=0;i<3;i++)

{
for(j=0;j<6;j++)

printf(" %.1f",murphy[i][j]);
printf("\n");

}

//line spaces
printf("\n");
printf("\n");
//test print
printf("%.1lf",max);
//line spaces
printf("\n");
printf("\n");
//test print
printf("%.1lf",min);

return 0;

}```

2. > printf("Enter Degree of Difficulty For Dive %d Diver 1 (1-4) >>",counter_2);
> scanf("%lf",&murphy[i][j]);
What is the value of j at this point?
Bet it isn't zero like you expect

Try
scanf("%lf",&murphy[i][0]);

> for (i=0;i<6;i++)
...
> for(i=0;i<3;i++)
Be consistent about whether i is subscripting the rows or columns of the 2D array
Better yet, rename i,j to be row,col

Your approach to indentation needs work as well. If it looks OK in your editor, then turn off TABS because they invariably result in a mess when you copy/paste code to the board.

3. Huge Thx Salem...

I'm getting in the missing data now, but It still needs a bit of work on min and max...its my loops that are causing it...as you spotted..so I'm off to fix that

Praxis

4. Originally posted by praxis
Huge Thx Salem...

I'm getting in the missing data now, but It still needs a bit of work on min and max...its my loops that are causing it...as you spotted..so I'm off to fix that

Praxis
Your min test needs a major overhaul. All you are going to get is the last min value that's less than max.

5. Yep the Min and Max were wrong...but its fixed now...
That's the fun part ..fixing your misteeks
Thx