example code

can anyone please post an example code of a program who sends an float 2d array into function that do somthing on all the cells in the array
i need to see how that look likes
i didnt got the pointers thing in array

thanks
chen
closed account (4Gb4jE8b)
umm. no. You're asking for way to much. lower it down a bit.
closed account (D80DSL3A)
OK - I'll step up to counter that rude response. I think most are here to be helpful.
Here's an example for you to examine:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<iostream>
using std::cout;
using std::endl;

const int cols = 5;// stuck with 5 columns for arrays, but rows may vary.

void INITarray(float arr[][cols], int r);// prototype

int main()
{	
	const int rowsA = 3;
	float arrayA[rowsA][cols];// 3x5 array

	const int rowsB = 6;
	float arrayB[rowsB][cols];// 6x5 array

	INITarray( arrayA,rowsA);// arrayA passed to function
	INITarray( arrayB,rowsB);// arrayB passed to function

	return 0;
}

void INITarray(float arr[][cols], int r)// definition
{
	cout << "Array elements are:" << endl;
	for(int i=0; i<r; i++)
	{
		for(int j=0; j<cols; j++)
		{
			arr[i][j] = static_cast<float>(i+j);// element values = sum of row and column
			cout << " " << arr[i][j];
		}
		cout << endl;
	}
	cout << endl;
	return;
}
it wasn't rude he was absolutely right, he came here asking for a complete program, having shown nothing which suggested he'd given it any thought himself.
closed account (4Gb4jE8b)
well, i absolutely didn't mean to be rude, so my apologies. But I was going along the same lines as quirky was. I'm perfectly fine with analyzing code or looking for mistakes, but I'm not going to, and most won't (and ethically shouldn't) do someones homework. This is especially true when the question isn't even formatted grammatically correct, or at least with correct use of commas, periods and the like, capitalization often falls through and i understand that, but commas and periods are a necessity. This of course is void if they specifically mention that their English is poor.

edit: it's called forum etiquette.
Last edited on
closed account (D80DSL3A)
I guess I overreacted. Sorry for that headlessgargoyle. I agree with your reasons. A respectful effort should be shown by the poster. I think I responded as I did because no explanation was offered.
I automatically assumed that his poor grammar meant that English is not his native language.
closed account (4Gb4jE8b)
I never make that assumption anymore, as I've extremely offended people by doing so. The evolution of texting and l33t as second nature to today's, and arguably to an extent, the youth of the 90's has made grammar fall by the wayside, much to the dismay of people who want to be able to understand what someone is saying. As a younger adult myself, and an up and coming programmer, I see no reason why this specific field wouldn't be infected with these same people as well.
thanks for the one who want to help
and for the rest
i didnt want u to do my homework
i just asked for an example for somthing like that
i didnt asked u to write somthing specialy for me
u dont have to answer u know that
so
next time
just save yourself the time and just dont answer
i want to see how using a function with 2d array look like
i guess thers few people here with this kind of program on thier computer
and this r the people i adreesed for

so thanks again for those who supported

chen
Topic archived. No new replies allowed.