What are the advantages and disadvantages of array in c?

Answer:
arrays are very very useful in c++
for example if you need to store marks of 100 students..... u will have to make 100 int type data types............ so long.... but arrays can do the same work in a few seconds.....


its prototype is like this..
void main ()
{
int a[100]; // 100 here is the size of the array
int i;
for(i=0;i<100;i++)
{
cin>>a[i];
}
}


this will take data of all 100 students in an array form....

..... how will PC store these data....


subscripts 0 1 2 3 5...... 100
data 9 4 7 4 6...... 8


it will be like

a[0]= 9
a[1]= 4
a[2]= 7
a[3]= 4
a[4]= 6
....
a[100]= 8


DISADVANTAGES....

..... THERE ARE NO DISADVANTAGES ABOUT ARRAYS IN C++

ARRAYS ARE THE HEART OF C++ AND OTHER PROGRAMING LANGUAGES.....


ARRAYS ONLY AND ONLY HAVE A LOTZZZ OF ADVANTAGES....... TIME CONSUMING, EASY..... ETC...

ARRAYS ARE THE BASIC OF C++.......







BUT SO FAR SEEN AS A STUDENT (ME) ARRAYS SOMETIMES BECOME BIG PROBLEM.... FOR EXAMPLE IF I HAVE TO SWAP THE BIGGEST ELEMENT OF THE ARRAY WITH 1.........

I WILL HAVE TO CREATE AN ALGORITHM TO FIND A WAY TO DO IT......

BUT IN SIMPLE DATA TYPE.... I COULD DO IT AS...

A=1...

.....

HOPE IT WAS USEFUL.....

- Sundeep Singh
First answer by ID0018321107. Last edit by ID0018321107. Question popularity: 1 [recommend question].