You are using a version without Ads of this website. Please, consider donating:

### i'm stuck

can anybody help me with this source code. seems like something is not right with the function...

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243`` ``````/*Write a program that reads in a two-dimensional array representing the coordinates of points in space. The program should determine the largest absolute value in the array and scale each element of the array by dividing it by this largest value. The new array, which is called the normalized array, should have the largest value. The program consists of two functions: • main() – obtains the number of data points, and the x and y coordinates of each point. • normalize() – normalize the array.*/ #include #include int normalize(int input[][1], int row, int col); int main() { int row1=2; int col1=2; int b[1][1]; int ans; printf("Enter the coordinate of x1:"); scanf("%d",&b[0][0]); printf("Enter the coordinate of y1:"); scanf("%d",&b[0][1]); printf("Enter the coordinate of x2:"); scanf("%d",&b[1][0]); printf("Enter the coordinate of y2:"); scanf("%d",&b[1][1]); ans=normalize(b[][1],row1,col1); printf("the highest value is %d",ans); system("pause"); return 0; } int normalize(int input[][1], int row, int col) { int i, j; int highest = input[0][0]; for( i = 0; i < row; i++) for( j = 0; j < col; j++) if ( input[i][j] > highest) highest = input[i][j]; return highest; }``````

the problem is at line 'ans=normalize(b[][1],row1,col1);' the compiler said there is an expected value b4 the']'.. but if i put anything there'll be another problem occur. :(
thanks :D
Last edited on
Firstly, edit your post so it uses code tags - the <> button on the right
So it looks like this:

 ``123456789101112`` ``````int normalize(int input[][1], int row, int col) { int i, j; int highest = input[0][0]; for( i = 0; i < row; i++) for( j = 0; j < col; j++) if ( input[i][j] > highest) highest = input[i][j]; return highest; }``````

If you have any compiler errors post those in full as well

Once you have done that, we can go from there.
i've done editing it. hope somebody can help me.. :)
these r the parameter error..

C:\Users\user\Desktop\1128541AssLab3.cpp In function `int main()':
26 C:\Users\user\Desktop\1128541AssLab3.cpp expected primary-expression before ']' token
Well its simple as this ,

ans=normalize(b[][1],row1,col1);

It should actually be :
ans=normalize(b,row1,col1);

only the array name , not the size .

Well the assignment was to be submitted on Saturday , but better late than never.

Also , according to the question your program is not complete , the absolute value calculation and the scaling is not done.

Good luck .

3:)
Also , just for the sake of it

it has to be int b[2][2] instead of b[1][1] in the declaration .

You are welcome.
thanks.. :D
try using cout and cin instead of printf and scanf its better
Topic archived. No new replies allowed.

You are using a version without Ads of this website. Please, consider donating: