DevX Home Today's Headlines   Articles Archive   Tip Bank   Forums

1. Registered User
Join Date
May 2010
Posts
1

hi all

1-Declare 8 by 8 integer array.
2-write a function that is named Getmax that will receive the array that was declared in part 1 as a parameter and find the maximum value among array's secondary diagonal elements .The function should return the maximum value.

2. Registered User
Join Date
Oct 2007
Posts
369
Sounds like you're asking someone to do your homework. You need to narrow down the questions to show you're working on your own.
Do you know how to declare an array? Do you know how to declare a two-dimensional array in C/C++?

3. Senior Member
Join Date
Dec 2003
Posts
3,366
something like this. I refuse to use 2d arrays, they are impossible to resize or work with, but the general idea is here. I assume secondary diagonal is bottom left to upper right, yes? Here, 0,0 is upper left so 56 is of course the bottom right and 7 is the upper right, of course. Besides, if its for a grade, your teacher will know right off that this isnt your work if you turn it in as - is without understanding it. If its to understand the problem and learn something, this offers much.

int *x = new int[64];

int getmax(int * a)
{
int max = a[56];

for(int i = 7; i <56; i+=7)
{
if(a[i] > max)
max = a[i];
}
return max;
}

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 FAQ Latest Articles Java .NET XML Database Enterprise