Question:

How does array works in c++ ?

by  |  earlier

0 LIKES UnLike

How does array works in c++ ?

 Tags:

   Report

2 ANSWERS


  1. Hi

    An array in any programming language is a collection of data of the same type:

    E.g.

    int Array1[32];

    Is and array of 32 integers and memory will be set aside to hold these.

    Example:

    #include <iostream>

    int main()

    {

       int anArray[4];

       int i;

       for ( i = 0 ; i < 4 ; i++)

       {

           anArray[i] = i * i;

       }

       for ( i = 0 ; i < 4 ; i++)

       {

           std::cout << "Num " << i << " Squared is " << anArray[i]  << '\n' ;

       }

    }

    A bit trivial but illustrates the point.

    Good Luck

    G


  2. Here are two videos that explains C++ arrays:

    One-dimensional

    http://xoax.net/comp/cpp/console/Lesson1...

    Multi-dimensional

    http://xoax.net/comp/cpp/console/Lesson2...

    Here are some additional examples:

    http://xoax.net/comp/cpp/reference/array...

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions