what are arrays in c++ programming how to do or what is meant by swaping?

Recommended Answers

All 2 Replies

Think of a simple array as a list of objects, integers say. You can create them in two ways:

int* pAnArray = new int [200] ;

which creates a list of 200 integers from pAnArray[0] to pAnArray[199]. You need to free the memory after use like this:

delete [] pAnArray ;

Or you can create an array like this:

int AnotherArray[200] ;

which again, in this example, creates a list of 200 integers. This does not need to be deleted explicitly.

You can fill the arrays like this:

for (int i = 0 ; i < 200 ; i++) {
   AnArray[i] = ...some number....
}

These are 1 dimensional arrays. See your test book for 2d and 3d arrays...

Are you learning C++ ? What material are you using ? Any decent C++ book or online resource should give you a good explanation of arrays and how they are used. Try this http://www.cplusplus.com/doc/tutorial/arrays/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.