|
@Shajeel: this is machine era.So mistaken done cant be reverted back.
always you will get choices as 0 or 1.i m happy that i have voted for 1.
|
|
|
|
|
For some things such as color indexing we need 0s to indicate lack of that color. But if we are referencing days of the week, months of the year? Month[0]? Day[0]?
Someone friends have posted strong arguments for 0 base, which (sadly) seem rational to me. But brothers, who am I, but a brainwashed programmer after decades of accepting computer supremacy over my fellow beings? 99.9% of normal humans will not even understand what these friends are talking about! Yes, 90% of us have forsaken our fellow humans in this survey.
/*
I am with Skynet when it all happens any way. This biological hardware with extreme inflexibility to refactoring, and lack of scalability after maturity, is just not the way ahead for evolution.
We need new hardware - as bodies - for intellectual beings. Bodies that can work in a vacuum, can tolerate wider range of temperature, can easily accept exchange of spare parts in case of failure and last but not least, ability to be erased and reprogrammed as the need arises (if only I could erase some of my habits!).
This is the beginning of the end for carbon based, biological hardware.
*/
|
|
|
|
|
Array indices are offsets. That's why they start at 0, period.
ar[n] means: addressof(ar) + sizeof(element) * n . This should explain everything. How old are you in years until your first birthday? Right, zero. So your first year is my_life[0] .
So according to the results of this survey 10% of the programmers here don't know the basics of mathematics and computers.
Well, at least they read codeproject.
|
|
|
|
|
Don't get me wrong, I voted 0 too. But in mathematics, vector indexing (a vector is a 1-dimensional array) starts at 1. Ditto for matrices, which are 2D arrays.
|
|
|
|
|
And index? And why there are no multiple choice and free answers?
modified on Tuesday, March 8, 2011 10:49 AM
|
|
|
|
|
I suggest you leave the site if you really don't know.
|
|
|
|
|
I registered here to learn new things. But this site looks so unfriendly...
|
|
|
|
|
Alex,
Don't mind these guys. They are not trying to be hurtful.
It is human nature to reflect what is inside and project and super-impose it to what's coming from the outside, to the point that we stop seeing the world as is and see it as we are.
Seems like you are new to programming and this site, and these experienced old-timers did not include that possibility in their calculations. But they mean well. They just did not want non-funny old-timers polluting the site with taste-less comments.
But yours is valid and this site belongs to you. Stick with it. I have learnt a world of programming (and non-programming) knowledge from the guys contributing to this site.
Welcome to Code-Project!
|
|
|
|
|
he got you
see his profile
|
|
|
|
|
I stand by my word: He is still welcome to CodeProject. He does not seem any crazier than the rest of us.
|
|
|
|
|
what? are you out of your mind?
He has been a member for 9+ years, wrote 14 articles. By any standard he is not NEW at all. He was poking fun at the community. Ok, do you still stand by your words.
|
|
|
|
|
|
Don't leave this site coz its invaluable. Yes there mean people out there but they are sadly here to stay.
An array is just a variable that stores more than one value at the same time. I assume you know what a variable is so take an int variable as an example. An int variable can only store one value at any given time so it can't hold a collection of values, say the total number of students in each class of a school. This is where an array comes handy.
An array usually stores values of only one type so you can't mix integers with strings unless the array has been set to contain type Object.
An array stores these items in a column like manner. So we have the first item at the top, the second item follows and so on. Each item has index that indicates its position in the array. The first item usually occupies index 0, the second index 1, the third index 2 and the list continues depending on how many items the array has been set to hold.
To declare an array that stores five items of type integer in c# code proceed as follows;
int[] noOfStudents = new int[5];
we now have an array that explicitly stores only values that are of type integer (whole numbers only). To set the first item to hold 20 use the following code:
noOfStudents[0]=20;
since the array has been set to hold a maximum of 5 values, the last index (the position an item is found at) is therefore 4 since we start counting from index 0.
To get an item in the third index proceed as follows:
int value=noOfStudents[2];
remember we start counting from index 0. If you try to set a value at index 45 and the array has been set to hold 20 values then you will get an error/exception. Likewise if you try to set a value to an element that is beyond the maximum possible items that the array has been set to hold then you will get an error that may state (out of bounds exception). Read more on arrays coz this was just an introduction. Hope it helped you.
|
|
|
|
|
The gui who asked "what is an array" had already written 14 articles on CP (just look is profile...)
The question was meant to be existential, not "technical".
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Yeah, figured I'd help the next noob who came along doing a class assignment on arrays. Was also kinda drunk and feeling generous.
|
|
|
|
|
But yeah, he got me. Should be the most epic April Fools joke
|
|
|
|
|
Come on guys. Give new people a break. Have we forgotten how we started? Remember: "Every master was once a disaster".
|
|
|
|
|
Are you really this retarded, or are you making a piss-poor attempt at being funny?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Yes, I am making a piss-poor attempt at being funny, and I am really happy having these pathetic replies! Now this is really funny.
|
|
|
|
|
Alex Fr wrote: what is array?
A kind of fish.
Alex Fr wrote: what is index?
Usually wood or steel.
Are you sure you are on the correct site? This is the Code project, not the cod project.
|
|
|
|
|
Thanks, but another answer I have is that they are like like pizza and tomato. It looks so confusing...
|
|
|
|
|
|
Wow dude , really you are at the wrong place.
I am of opinion that an array should always start at 0 becuase of the decimal system, starts at 0, and -1 is a good way to show that nothing was selected
"And why there are no multiple choice" - even if the choice has two possible answer it is still "multiple"
"and free answers?" - Because tehres are members of programming forums that has no clue what an array is
Chona1171
Web Developer (C#), Silverlight
|
|
|
|
|
Multiple choice allows to select more than one answer! It looks like you are at the wrong place
But what the hell is array ???
|
|
|
|
|
you have two possible answers and last time i checked (2 > 1) == true;
Basic English should tell you that:
An array is a systematic arrangement of objects, usually in rows and columns.
Referred to in the following fields of study:
Computer science
math and stats
biology
astronomy
technology
and music
So here's my question why join a programming forum ?
Chona1171
Web Developer (C#), Silverlight
|
|
|
|